public function pageContent(Page $page)
 {
     $content = $page->getContent();
     if (!$content) {
         return '';
     }
     if ($page->hasFeature('layout')) {
         if (!is_array($content)) {
             throw new \InvalidArgumentException(sprintf('Page with id "%s" has a layout but no array content', $page->getId()));
         }
         $layoutFeature = $page->getFeature('layout');
         $layout = $layoutFeature->getContent();
         $search = array();
         $replace = array();
         foreach ($content as $key => $value) {
             $search[] = '{{' . $key . '}}';
             $replace[] = $value;
         }
         $content = preg_replace_callback('/[{]{2}([^}]*)[}]{2}/i', function ($key) use($content) {
             return isset($content[$key[1]]) ? $content[$key[1]] : '<!-- NO-CONTENT -->';
         }, $layout);
     }
     if (is_array($content)) {
         $content = implode('', $content);
     }
     return $content;
 }