Skip to content

Commit

Permalink
fix #1504 process_twig and frontmatter.yaml (#1507)
Browse files Browse the repository at this point in the history
  • Loading branch information
the4thamigo-uk authored and rhukster committed Jun 4, 2017
1 parent 634f2bd commit 9c0f06e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public function init(\SplFileInfo $file, $extension = null)
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])) {
Expand Down Expand Up @@ -325,17 +325,17 @@ public function header($var = null)
$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';
if (file_exists($frontmatter_file)) {
$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([
Expand Down

0 comments on commit 9c0f06e

Please sign in to comment.