diff --git a/.gitignore b/.gitignore index ec9a1ddf..5afbaf36 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules composer.lock /vendor .phpunit.result.cache +.phpunit.cache diff --git a/src/Cascade.php b/src/Cascade.php index dd683978..a9e790d4 100644 --- a/src/Cascade.php +++ b/src/Cascade.php @@ -212,13 +212,13 @@ protected function parse($key, $item) : $item; // If they have antlers in the string, they are on their own. - if (is_string($raw) && Str::contains($item, '{{')) { - return $this->parseAntlers($item); + if (is_string($raw) && Str::contains($raw, '{{')) { + return $this->parseAntlers($raw); } // For source-based strings, we should get the value from the source. - if (is_string($raw) && Str::startsWith($item, '@seo:')) { - $field = explode('@seo:', $item)[1]; + if (is_string($raw) && Str::startsWith($raw, '@seo:')) { + $field = explode('@seo:', $raw)[1]; if (Str::contains($field, '/')) { $field = explode('/', $field)[1]; diff --git a/tests/CascadeTest.php b/tests/CascadeTest.php index fdfe4f9e..92dabc5c 100644 --- a/tests/CascadeTest.php +++ b/tests/CascadeTest.php @@ -108,6 +108,24 @@ public function it_generates_compiled_title_from_cascaded_parts() $this->assertEquals('Cool Writings >>> Jamaica', $data['compiled_title']); } + /** @test */ + public function it_parses_antlers() + { + $entry = Entry::findByUri('/about')->entry(); + + $entry->data(['favourite_colour' => 'Red'])->save(); + + $data = (new Cascade) + ->with(SiteDefaults::load()->all()) + ->with([ + 'description' => '{{ favourite_colour | upper }}', + ]) + ->withCurrent($entry) + ->get(); + + $this->assertEquals('RED', $data['description']); + } + /** @test */ public function it_parses_field_references() {