diff --git a/VERSION b/VERSION index dedcc7d..10c2c0c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.9.1 +2.10.0 diff --git a/composer.json b/composer.json index 795937f..63173c6 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,14 @@ { "name": "phpoole/library", "description": "An intuitive PHP library to create a static website.", - "keywords": ["static", "website", "generator", "flat file", "markdown", "twig"], + "keywords": [ + "static", + "website", + "generator", + "flat file", + "markdown", + "twig" + ], "homepage": "https://github.com/PHPoole/library", "license": "MIT", "type": "library", @@ -35,7 +42,7 @@ "phpunit/phpunit": "7.2.7" }, "autoload": { - "psr-4" : { + "psr-4": { "PHPoole\\": "src" } }, @@ -63,6 +70,8 @@ "php coveralls.phar -v" ], "api-docs-install": "curl -O http://get.sensiolabs.org/sami.phar", - "api-docs-build": "php sami.phar update sami.php" + "api-docs-build": "php sami.phar update sami.php", + "post-install-cmd": "cd tests/fixtures/website;composer install;", + "post-update-cmd": "cd tests/fixtures/website;composer update;" } } diff --git a/src/Config.php b/src/Config.php index 29ad74c..8384a46 100644 --- a/src/Config.php +++ b/src/Config.php @@ -131,13 +131,17 @@ public function __construct($config = null) { $data = new Data(self::$defaultData); - if ($config instanceof self) { - $data->importData($config->getAll()); - } elseif (is_array($config)) { - $data->import($config); + if ($config) { + if ($config instanceof self) { + $data->importData($config->getAll()); + } elseif (is_array($config)) { + $data->import($config); + } } - // Apply environment variables + /** + * Apply environment variables. + */ $applyEnv = function ($array) use ($data) { $iterator = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($array), @@ -159,6 +163,24 @@ public function __construct($config = null) $this->setFromData($data); } + /** + * Import array config to current config. + * + * @param array $config + * + * @return $this + */ + public function import($config) + { + if (is_array($config)) { + $data = $this->getAll(); + $origin = $data->export(); + $data->import($config); + $data->import($origin); + $this->setFromData($data); + } + } + /** * Set config data. * @@ -272,35 +294,13 @@ public function getDestinationDir() return $this->destinationDir; } - /** - * Is config has a valid theme? - * - * @throws Exception - * - * @return bool - */ - public function hasTheme() - { - if ($this->get('theme')) { - if (!Util::getFS()->exists($this->getThemePath($this->get('theme')))) { - throw new Exception(sprintf( - "Theme directory '%s/%s/layouts' not found!", - $this->getThemesPath(), - $this->get('theme') - )); - } - - return true; - } - - return false; - } - /** * Path helpers. */ /** + * Return content directory path. + * * @return string */ public function getContentPath() @@ -309,6 +309,8 @@ public function getContentPath() } /** + * Return templates directory path. + * * @return string */ public function getLayoutsPath() @@ -317,6 +319,18 @@ public function getLayoutsPath() } /** + * Return themes directory path. + * + * @return string + */ + public function getThemesPath() + { + return $this->getSourceDir().'/'.$this->get('themes.dir'); + } + + /** + * Return internal templates directory path. + * * @return string */ public function getInternalLayoutsPath() @@ -325,37 +339,81 @@ public function getInternalLayoutsPath() } /** + * Return output directory path. + * * @return string */ - public function getThemesPath() + public function getOutputPath() { - return $this->getSourceDir().'/'.$this->get('themes.dir'); + return $this->getSourceDir().'/'.$this->get('output.dir'); } /** - * @param string $theme - * @param string $dir + * Return static files directory path. * * @return string */ - public function getThemePath($theme, $dir = 'layouts') + public function getStaticPath() { - return $this->getSourceDir().'/'.$this->get('themes.dir').'/'.$theme.'/'.$dir; + return $this->getSourceDir().'/'.$this->get('static.dir'); } /** - * @return string + * Themes helpers. */ - public function getOutputPath() + + /** + * Return theme(s). + * + * @return array|null + */ + public function getTheme() { - return $this->getSourceDir().'/'.$this->get('output.dir'); + if ($themes = $this->get('theme')) { + if (is_array($themes)) { + return $themes; + } + + return [$themes]; + } } /** + * Has a (valid) theme(s)? + * + * @throws Exception + * + * @return bool + */ + public function hasTheme() + { + if ($themes = $this->getTheme()) { + foreach ($themes as $theme) { + if (!Util::getFS()->exists($this->getThemeDirPath($theme, 'layouts'))) { + throw new Exception(sprintf( + "Theme directory '%s/%s/layouts' not found!", + $this->getThemesPath(), + $theme + )); + } + } + + return true; + } + + return false; + } + + /** + * Return the path of a specific theme's directory. + * + * @param string $theme + * @param string $dir + * * @return string */ - public function getStaticPath() + public function getThemeDirPath($theme, $dir = 'layouts') { - return $this->getSourceDir().'/'.$this->get('static.dir'); + return $this->getThemesPath().'/'.$theme.'/'.$dir; } } diff --git a/src/PHPoole.php b/src/PHPoole.php index 9787f6a..5c104f7 100644 --- a/src/PHPoole.php +++ b/src/PHPoole.php @@ -37,6 +37,7 @@ class PHPoole * @see build() */ protected $steps = [ + 'PHPoole\Step\ImportConfig', 'PHPoole\Step\LocateContent', 'PHPoole\Step\CreatePages', 'PHPoole\Step\ConvertPages', @@ -101,8 +102,9 @@ class PHPoole */ public function __construct($config = null, \Closure $messageCallback = null) { - $this->setConfig($config); - $this->config->setSourceDir(null)->setDestinationDir(null); + $this->setConfig($config) + ->setSourceDir(null) + ->setDestinationDir(null); $this->setMessageCallback($messageCallback); } @@ -229,6 +231,7 @@ public function setMessageCallback($messageCallback = null) if ($messageCallback === null) { $messageCallback = function ($code, $message = '', $itemsCount = 0, $itemsMax = 0) { switch ($code) { + case 'CONFIG': case 'LOCATE': case 'CREATE': case 'CONVERT': @@ -241,6 +244,7 @@ public function setMessageCallback($messageCallback = null) $log = sprintf("%s\n", $message); $this->addLog($log); break; + case 'CONFIG_PROGRESS': case 'LOCATE_PROGRESS': case 'CREATE_PROGRESS': case 'CONVERT_PROGRESS': diff --git a/src/Renderer/Layout.php b/src/Renderer/Layout.php index 8218717..18ba88a 100644 --- a/src/Renderer/Layout.php +++ b/src/Renderer/Layout.php @@ -38,17 +38,20 @@ public function finder(Page $page, Config $config) // take the first available layout foreach ($layouts as $layout) { - // is it in layouts dir? + // is it in layouts/ dir? if (Util::getFS()->exists($config->getLayoutsPath().'/'.$layout)) { return $layout; } - // is it in theme dir? + // is it in /layouts/ dir? if ($config->hasTheme()) { - if (Util::getFS()->exists($config->getThemePath($config->get('theme')).'/'.$layout)) { - return $layout; + $themes = $config->getTheme(); + foreach ($themes as $theme) { + if (Util::getFS()->exists($config->getThemeDirPath($theme, 'layouts').'/'.$layout)) { + return $layout; + } } } - // is it in internal dir? + // is it in res/layouts/ dir? if (Util::getFS()->exists($config->getInternalLayoutsPath().'/'.$layout)) { return $layout; } @@ -120,33 +123,34 @@ protected static function fallback(Page $page) break; default: $layouts = [ - // '$section/page.html.twig', // '$section/$layout.twig', // '$layout.twig', + // '$section/page.html.twig', // 'page.html.twig', '_default/page.html.twig', ]; + $layouts = array_merge( + ['page.html.twig'], + $layouts + ); + if ($page->getSection()) { $layouts = array_merge( [sprintf('%s/page.html.twig', $page->getSection())], $layouts ); - if ($page->getLayout()) { - $layouts = array_merge( - [sprintf('%s/%s.twig', $page->getSection(), $layout)], - $layouts - ); - } } - $layouts = array_merge( - ['page.html.twig'], - $layouts - ); if ($page->getLayout()) { $layouts = array_merge( [sprintf('%s.twig', $layout)], $layouts ); + if ($page->getSection()) { + $layouts = array_merge( + [sprintf('%s/%s.twig', $page->getSection(), $layout)], + $layouts + ); + } } } diff --git a/src/Step/CopyStatic.php b/src/Step/CopyStatic.php index a821a5e..6c8c923 100644 --- a/src/Step/CopyStatic.php +++ b/src/Step/CopyStatic.php @@ -39,23 +39,25 @@ public function process() $count = 0; call_user_func_array($this->phpoole->getMessageCb(), ['COPY', 'Copying static files']); - // copy theme static dir if exists + // copy /static/ dir if exists if ($this->phpoole->getConfig()->hasTheme()) { - $theme = $this->phpoole->getConfig()->get('theme'); - $themeStaticDir = $this->phpoole->getConfig()->getThemePath($theme, 'static'); - if (Util::getFS()->exists($themeStaticDir)) { - $finder = new Finder(); - $finder->files()->in($themeStaticDir); - $count += $finder->count(); - Util::getFS()->mirror( - $themeStaticDir, - $this->phpoole->getConfig()->getOutputPath(), - null, - ['override' => true] - ); + $themes = array_reverse($this->phpoole->getConfig()->getTheme()); + foreach ($themes as $theme) { + $themeStaticDir = $this->phpoole->getConfig()->getThemeDirPath($theme, 'static'); + if (Util::getFS()->exists($themeStaticDir)) { + $finder = new Finder(); + $finder->files()->in($themeStaticDir); + $count += $finder->count(); + Util::getFS()->mirror( + $themeStaticDir, + $this->phpoole->getConfig()->getOutputPath(), + null, + ['override' => true] + ); + } } } - // copy static dir if exists + // copy static/ dir if exists $staticDir = $this->phpoole->getConfig()->getStaticPath(); if (Util::getFS()->exists($staticDir)) { $finder = new Finder(); diff --git a/src/Step/ImportConfig.php b/src/Step/ImportConfig.php new file mode 100644 index 0000000..ae2fde9 --- /dev/null +++ b/src/Step/ImportConfig.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPoole\Step; + +use PHPoole\Exception\Exception; +use PHPoole\Util; +use Symfony\Component\Yaml\Yaml; + +/** + * Import (themes) config. + */ +class ImportConfig extends AbstractStep +{ + const THEME_CONFIG_FILE = 'phpoole.yml'; + + /** + * {@inheritdoc} + * + * @throws Exception + */ + public function init($options) + { + if (!$this->config->hasTheme()) { + $this->process = false; + } + + $this->process = true; + } + + /** + * {@inheritdoc} + */ + public function process() + { + call_user_func_array($this->phpoole->getMessageCb(), ['CONFIG', 'Importing config']); + + try { + $themes = array_reverse($this->config->getTheme()); + $count = 0; + $max = count($themes); + foreach ($themes as $theme) { + $count++; + $themeConfigFile = $this->config->getThemesPath().'/'.$theme.'/'.self::THEME_CONFIG_FILE; + if (Util::getFS()->exists($themeConfigFile)) { + $themeConfig = Yaml::parse( + file_get_contents($themeConfigFile) + ); + $this->config->import($themeConfig); + $message = sprintf('%s: config imported', $theme); + } else { + $message = sprintf('%s: no config file', $theme); + } + call_user_func_array($this->phpoole->getMessageCb(), ['CONFIG_PROGRESS', $message, $count, $max]); + } + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } + } +} diff --git a/src/Step/RenderPages.php b/src/Step/RenderPages.php index c2cb11d..7e400f5 100644 --- a/src/Step/RenderPages.php +++ b/src/Step/RenderPages.php @@ -63,13 +63,13 @@ public function process() $count++; $rendered = $this->phpoole->getRenderer()->render( - (new Layout())->finder($page, $this->config), + $layout = (new Layout())->finder($page, $this->config), ['page' => $page] ); $page->setVariable('rendered', $rendered); $this->phpoole->getPages()->replace($page->getId(), $page); - $message = $page->getPathname() ?: 'index'; + $message = sprintf('%s (%s)', ($page->getPathname() ?: 'index'), $layout); call_user_func_array($this->phpoole->getMessageCb(), ['RENDER_PROGRESS', $message, $count, $max]); } } @@ -83,15 +83,18 @@ protected function getAllLayoutsPaths() { $paths = []; - // website + // layouts/ if (is_dir($this->config->getLayoutsPath())) { $paths[] = $this->config->getLayoutsPath(); } - // theme + // /layouts/ if ($this->config->hasTheme()) { - $paths[] = $this->config->getThemePath($this->config->get('theme')); + $themes = $this->config->getTheme(); + foreach ($themes as $theme) { + $paths[] = $this->config->getThemeDirPath($theme); + } } - // internal + // res/layouts/ if (is_dir($this->config->getInternalLayoutsPath())) { $paths[] = $this->config->getInternalLayoutsPath(); } diff --git a/tests/Build.php b/tests/Build.php index 9399eb8..9b8a602 100644 --- a/tests/Build.php +++ b/tests/Build.php @@ -15,6 +15,7 @@ class Build extends \PHPUnit\Framework\TestCase { protected $wsSourceDir; protected $wsDestinationDir; + const DEBUG = false; public function setUp() { @@ -25,8 +26,10 @@ public function setUp() public function tearDown() { $fs = new Filesystem(); - $fs->remove($this->wsDestinationDir.'/_site'); - $fs->remove(__DIR__.'/../_cache'); + if (!self::DEBUG) { + $fs->remove($this->wsDestinationDir.'/_site'); + $fs->remove(__DIR__.'/../_cache'); + } } public function testBuid() @@ -66,7 +69,10 @@ public function testBuid() ], 'googleanalytics' => 'POUET', ], - 'theme' => 'theme', + 'theme' => [ + 'a-theme', + 'hyde', + ], 'static' => [ 'exclude' => [ 'test.txt', diff --git a/tests/fixtures/website/composer.json b/tests/fixtures/website/composer.json new file mode 100644 index 0000000..44a55b2 --- /dev/null +++ b/tests/fixtures/website/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "phpoole/theme-hyde": "^1.10" + } +} diff --git a/tests/fixtures/website/composer.lock b/tests/fixtures/website/composer.lock new file mode 100644 index 0000000..5d14cbe --- /dev/null +++ b/tests/fixtures/website/composer.lock @@ -0,0 +1,103 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "36c62b2016cdc2dd1015ce3980c3e843", + "packages": [ + { + "name": "phpoole/theme-hyde", + "version": "1.10.1", + "source": { + "type": "git", + "url": "https://github.com/PHPoole/theme-hyde.git", + "reference": "c6fa10b1cb43952e0fe8292135b8c91ac79d5f3d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPoole/theme-hyde/zipball/c6fa10b1cb43952e0fe8292135b8c91ac79d5f3d", + "reference": "c6fa10b1cb43952e0fe8292135b8c91ac79d5f3d", + "shasum": "" + }, + "require": { + "phpoole/theme-installer": "^1.2" + }, + "type": "phpoole-theme", + "extra": { + "name": "hyde", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPoole Hyde theme", + "keywords": [ + "Hyde", + "phpoole", + "theme" + ], + "time": "2018-11-14T13:42:07+00:00" + }, + { + "name": "phpoole/theme-installer", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/PHPoole/theme-installer.git", + "reference": "bcad945ccf467351dcbf2765c99394ba33d6bf2f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPoole/theme-installer/zipball/bcad945ccf467351dcbf2765c99394ba33d6bf2f", + "reference": "bcad945ccf467351dcbf2765c99394ba33d6bf2f", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPoole\\PHPoole\\Composer\\PHPoolePlugin", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-0": { + "PHPoole\\PHPoole\\Composer": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Arnaud Ligny", + "email": "arnaud@ligny.org", + "homepage": "http://narno.org", + "role": "Developer" + } + ], + "description": "Installer for PHPoole themes", + "keywords": [ + "installer", + "phpoole", + "themes" + ], + "time": "2018-01-15T17:40:29+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/tests/fixtures/website/layouts/_default/list.html.twig b/tests/fixtures/website/layouts/_default/list.html.twig deleted file mode 100644 index 731a1b7..0000000 --- a/tests/fixtures/website/layouts/_default/list.html.twig +++ /dev/null @@ -1,33 +0,0 @@ -{% include 'include/header.html.twig' %} - -

Pages:

-{% if page.pagination is defined %} -
    - {% for item in page.pagination.pages %} -
  • - {{ item.title }} ({{ item.id }} - {{ item.date|date("d/m/Y") }}) -

    {{ item.content|excerpt }}

    -
  • - {% endfor %} -
-

- {% if page.pagination.prev is defined %} - Prev - {% endif %} - {% if page.pagination.prev is defined and page.pagination.next is defined %}|{% endif %} - {% if page.pagination.next is defined %} - Next - {% endif %} -

-{% else %} -
    - {% for item in page.pages %} -
  • - {{ item.title }} ({{ item.id }} - {{ item.date|date("d/m/Y") }}) -

    {{ item.content|excerptHtml }}

    -
  • - {% endfor %} -
-{% endif %} - -{% include 'include/footer.html.twig' %} diff --git a/tests/fixtures/website/layouts/_default/page.html.twig b/tests/fixtures/website/layouts/_default/page.html.twig deleted file mode 100644 index da7e94e..0000000 --- a/tests/fixtures/website/layouts/_default/page.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% include 'include/header.html.twig' %} - -

{{ page.title }}

- -{% block content %} -{{ page.content }} -{% endblock %} - -{% include 'include/footer.html.twig' %} diff --git a/tests/fixtures/website/layouts/_default/taxonomy.html.twig b/tests/fixtures/website/layouts/_default/taxonomy.html.twig deleted file mode 100644 index fba59fa..0000000 --- a/tests/fixtures/website/layouts/_default/taxonomy.html.twig +++ /dev/null @@ -1,12 +0,0 @@ -{% include 'include/header.html.twig' %} - -

{{ page.singular|title }} "{{ page.title }}"

-
    - {% for term in page.pagination.pages|sortByDate %} -
  • - {{ term.title }} -
  • - {% endfor %} -
- -{% include 'include/footer.html.twig' %} diff --git a/tests/fixtures/website/layouts/_default/terms.html.twig b/tests/fixtures/website/layouts/_default/terms.html.twig deleted file mode 100644 index 899d897..0000000 --- a/tests/fixtures/website/layouts/_default/terms.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{% include 'include/header.html.twig' %} - -

{{ page.plural }}

-
    - {% for name, term in page.terms %} -
  • {{ name }} ({{ term|length }})

    - -
  • - {% endfor %} -
- -{% include 'include/footer.html.twig' %} diff --git a/tests/fixtures/website/layouts/blog/page.html.twig b/tests/fixtures/website/layouts/blog/page.html.twig deleted file mode 100644 index e3a7a1f..0000000 --- a/tests/fixtures/website/layouts/blog/page.html.twig +++ /dev/null @@ -1,12 +0,0 @@ -{% extends '_default/page.html.twig' %} - -{% block content %} -{{ page.date|date }} -{{ page.content }} -{% if tag is defined %} -{% for tag in page.tags %} -#{{ tag }}  -{% endfor %} -{% endif %} -
{{ dump(page) }}
-{% endblock %} diff --git a/tests/fixtures/website/layouts/include/footer.html.twig b/tests/fixtures/website/layouts/include/footer.html.twig deleted file mode 100644 index 937af28..0000000 --- a/tests/fixtures/website/layouts/include/footer.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -

version: {{ phpoole.version }}

-{% include 'includes/googleanalytics.js.twig' %} - - diff --git a/tests/fixtures/website/layouts/include/header.html.twig b/tests/fixtures/website/layouts/include/header.html.twig deleted file mode 100644 index 5317e3c..0000000 --- a/tests/fixtures/website/layouts/include/header.html.twig +++ /dev/null @@ -1,11 +0,0 @@ - - - - - {{ page.title }} - {{ site.title }} - - - - -

{{ page.title }}

-{% include 'include/menu.html.twig' %} diff --git a/tests/fixtures/website/layouts/include/menu.html.twig b/tests/fixtures/website/layouts/include/menu.html.twig deleted file mode 100644 index b055d28..0000000 --- a/tests/fixtures/website/layouts/include/menu.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -

Menu:

-
    -{% for entry in site.menus.main|sortByWeight %} -
  • {{ entry.name }} ({{ entry.weight }})
  • -{% endfor %} -
diff --git a/tests/fixtures/website/layouts/index.html.twig b/tests/fixtures/website/layouts/index.html.twig deleted file mode 100644 index 4a862a5..0000000 --- a/tests/fixtures/website/layouts/index.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{% include 'include/header.html.twig' %} - -All pages: -
    -{% for item in site.pages|sortByDate %} -{% include 'include/page_li.html.twig' %} -{% endfor %} -
- -Blog pages: -
    -{% for item in site.pages|filterBy('section', 'blog') %} -{% include 'include/page_li.html.twig' %} -{% endfor %} -
- -Virtuals pages: -
    -{% for item in site.pages|filterBy('virtual', true) %} -{% include 'include/page_li.html.twig' %} -{% endfor %} -
- -{% include 'include/footer.html.twig' %} diff --git a/tests/fixtures/website/static/css/style.css b/tests/fixtures/website/static/css/_style.css similarity index 100% rename from tests/fixtures/website/static/css/style.css rename to tests/fixtures/website/static/css/_style.css diff --git a/tests/fixtures/website/themes/.gitignore b/tests/fixtures/website/themes/.gitignore new file mode 100644 index 0000000..f3a270d --- /dev/null +++ b/tests/fixtures/website/themes/.gitignore @@ -0,0 +1,3 @@ +/* +!.gitignore +!a-theme diff --git a/tests/fixtures/website/layouts/include/page_li.html.twig b/tests/fixtures/website/themes/a-theme/layouts/includes/page_li.html.twig similarity index 100% rename from tests/fixtures/website/layouts/include/page_li.html.twig rename to tests/fixtures/website/themes/a-theme/layouts/includes/page_li.html.twig diff --git a/tests/fixtures/website/themes/a-theme/layouts/index.html.twig b/tests/fixtures/website/themes/a-theme/layouts/index.html.twig new file mode 100644 index 0000000..87371f6 --- /dev/null +++ b/tests/fixtures/website/themes/a-theme/layouts/index.html.twig @@ -0,0 +1,31 @@ +{% extends '_default/page.html.twig' %} + +{% block content %} + +All pages: +
    +{% for item in site.pages|sortByDate %} +{% include 'includes/page_li.html.twig' %} +{% endfor %} +
+ +Blog pages: +
    +{% for item in site.pages|filterBy('section', 'blog') %} +{% include 'includes/page_li.html.twig' %} +{% endfor %} +
+ +Virtuals pages: +
    +{% for item in site.pages|filterBy('virtual', true) %} +{% include 'includes/page_li.html.twig' %} +{% endfor %} +
+ +Imported config (from theme(s)): +{% if site.foo is defined %} +

Variable `foo`=`{{ site.foo }}`

+{% endif %} + +{% endblock %} diff --git a/tests/fixtures/website/themes/a-theme/layouts/macro.html.twig b/tests/fixtures/website/themes/a-theme/layouts/macro.html.twig new file mode 100644 index 0000000..dcab67b --- /dev/null +++ b/tests/fixtures/website/themes/a-theme/layouts/macro.html.twig @@ -0,0 +1,6 @@ +{% extends '_default/page.html.twig' %} + +{% block content %} +{# page.content #} +{% include page.content_template %} +{% endblock %} diff --git a/tests/fixtures/website/themes/theme/layouts/project/page.html.twig b/tests/fixtures/website/themes/a-theme/layouts/project/page.html.twig similarity index 79% rename from tests/fixtures/website/themes/theme/layouts/project/page.html.twig rename to tests/fixtures/website/themes/a-theme/layouts/project/page.html.twig index 8680200..ac1fe0b 100644 --- a/tests/fixtures/website/themes/theme/layouts/project/page.html.twig +++ b/tests/fixtures/website/themes/a-theme/layouts/project/page.html.twig @@ -2,7 +2,7 @@ {% block content %} {{ page.content }} -Page from theme > layouts > project > page.html.twig +Page from 'a-theme > layouts > project > page.html.twig' {% if page.categories is defined %}
    {% for category in page.categories %} diff --git a/tests/fixtures/website/themes/a-theme/layouts/robots.txt.twig b/tests/fixtures/website/themes/a-theme/layouts/robots.txt.twig new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/tests/fixtures/website/themes/a-theme/layouts/robots.txt.twig @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/tests/fixtures/website/themes/a-theme/phpoole.yml b/tests/fixtures/website/themes/a-theme/phpoole.yml new file mode 100644 index 0000000..6a102a4 --- /dev/null +++ b/tests/fixtures/website/themes/a-theme/phpoole.yml @@ -0,0 +1,3 @@ +site: + title: Imported config + foo: bar