-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share variables shared via View::share() with Twig templates (#969)
Fixes #630 This allows global variables populated by the View::share('name', 'value') method to be used in Twig templates. The values will only be populated if they have not been specified as a global previously, to prevent overriding system globals such as this.page. It will also allow the pages themselves to still override the values if need be.
- Loading branch information
1 parent
0aaefeb
commit 090562a
Showing
6 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
modules/cms/tests/fixtures/themes/test/pages/shared-variable-override.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
url = '/shared-variable-override' | ||
== | ||
<?php | ||
function onStart() { | ||
$this['winterStatus'] = 'Is Coming'; | ||
} | ||
== | ||
<p>Winter {{ winterStatus }}</p> | ||
|
||
<p>{{ this.page.url }}</p> |
5 changes: 5 additions & 0 deletions
5
modules/cms/tests/fixtures/themes/test/pages/shared-variable.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
url = '/shared-variable' | ||
== | ||
<p>Winter {{ winterStatus }}</p> | ||
|
||
<p>{{ this.page.url }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters