From 9c0f06e306844b239ae5805aab9782f88b0270be Mon Sep 17 00:00:00 2001 From: the4thamigo-uk Date: Sun, 4 Jun 2017 21:21:28 +0100 Subject: [PATCH] fix #1504 process_twig and frontmatter.yaml (#1507) --- system/src/Grav/Common/Page/Page.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index c177a6a84..164ec8792 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -156,8 +156,8 @@ class Page protected function processFrontmatter() { // Quick check for twig output tags in frontmatter if enabled - if (Utils::contains($this->frontmatter, '{{')) { - $process_fields = $this->file()->header(); + $process_fields = (array)$this->header(); + if (Utils::contains(json_encode(array_values($process_fields)), '{{')) { $ignored_fields = []; foreach ((array)Grav::instance()['config']->get('system.pages.frontmatter.ignore_fields') as $field) { if (isset($process_fields[$field])) { @@ -325,10 +325,6 @@ class Page $this->header = (object)$file->header(); if (!Utils::isAdminPlugin()) { - // Process frontmatter with Twig if enabled - if (Grav::instance()['config']->get('system.pages.frontmatter.process_twig') === true) { - $this->processFrontmatter(); - } // If there's a `frontmatter.yaml` file merge that in with the page header // note page's own frontmatter has precedence and will overwrite any defaults $frontmatter_file = $this->path . '/' . $this->folder . '/frontmatter.yaml'; @@ -336,6 +332,10 @@ class Page $frontmatter_data = (array)Yaml::parse(file_get_contents($frontmatter_file)); $this->header = (object)array_replace_recursive($frontmatter_data, (array)$this->header); } + // Process frontmatter with Twig if enabled + if (Grav::instance()['config']->get('system.pages.frontmatter.process_twig') === true) { + $this->processFrontmatter(); + } } } catch (ParseException $e) { $file->raw(Grav::instance()['language']->translate([