-
-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Brand New Antlers Engine ✨ #4257
Changes from all commits
7c67d3b
6dd75d7
1096959
1110e6d
010ef12
7d3195f
3c682ef
45871d8
38c4efd
b09ff47
44f63f0
fc986eb
b948ed3
779ec62
ca73ac8
07e6260
8154035
87845c2
0977b4b
6aba8e7
b721146
0d8115a
0fe0501
b931a11
b629fce
6127e14
2bb9514
719e07b
8e2df5c
df519e9
ffcf17c
ccc1da7
348a5ec
eadb3b9
04968b0
4629687
db01ee2
11620c3
a9da6a5
89d4a9d
84ad60b
28531fc
08c4bcf
5e7abd9
b4d12a7
a1e317d
a284967
70591dc
b13dda8
5f04eda
95a6516
c49ba30
0b03b20
1dbdd31
6568572
75d4e8b
17bf05d
a74a3f9
81f271e
6648e1c
026fc6d
10f707d
62d50b5
17820de
131d6c3
547c4db
dd12cc2
b0d6829
621cad0
478d34d
552308a
e6d8401
80a67ee
369df64
13ecfff
11a240e
c83a870
6231f3d
bcc6957
94efaef
31957b7
7481a74
f946eb8
cffa529
b3f9a34
1d5b595
dc1c828
adceb4f
040bb0e
8b4fec5
64df06e
a40540a
039e86a
2f62883
67153e8
d1b7588
3a6a365
a955bee
4fb8eac
c60ebc1
bda197f
c5cc7b9
f127564
e9d3b22
58b7410
86e00e3
a588acf
746bfe0
4a5b356
430a16b
37bc192
7d9828b
84aaae5
ae4a440
fb5f8b3
a18362f
3ec8c7d
08e05a1
0c6b358
ccdf759
d48fbe5
b14efb4
7c1575c
0d4b9f8
49d34a4
f07d610
14cf012
d922214
a51529f
eb6112c
b9155c7
fcab0de
6fbfa19
bb84a8b
aea3c84
52dd1a9
dd6150f
0b81245
93192ce
294e5db
e0a7304
da14674
3a3a41b
c8287c2
0b1417a
534465f
b720de7
932819c
af8666e
1a9b854
57dbc67
d543707
079f908
d999864
dd3278f
09ea5ef
63f5d05
a3c2995
d48eb75
6762555
fb154f1
1926267
bff22c2
9b7cb84
d794763
e83c195
f52b15c
3abc6a4
bdd1c40
efcc6d7
694e031
b956002
010c9e5
96aa63d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Version | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The desired Antlers language version to utilize. Possibly values are: | ||
| - regex: Utilize pre-3.3 Antlers. Appropriate for existing sites. | ||
| - runtime: Utilizes >= 3.3 Antlers, recommended for new sites. | ||
| | ||
*/ | ||
|
||
'version' => 'regex', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Guarded Variables | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Any variable pattern that appears in this list will not be allowed | ||
| in any Antlers template, including any user-supplied values. | ||
| | ||
*/ | ||
|
||
'guardedVariables' => [ | ||
'config.app.key', | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Guarded Tags | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Any tag pattern that appears in this list will not be allowed | ||
| in any Antlers template, including any user-supplied values. | ||
| | ||
*/ | ||
|
||
'guardedTags' => [ | ||
|
||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Guarded Modifiers | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Any modifier pattern that appears in this list will not be allowed | ||
| in any Antlers template, including any user-supplied values. | ||
| | ||
*/ | ||
|
||
'guardedModifiers' => [ | ||
|
||
], | ||
|
||
]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment has nothing to do with this line, I'm just putting it here so we can have a discussion thread. I've found an issue regarding passing values into partials. I wasn't even sure how to write a test for it, so I've created a repo so you can see it. The bug is explained in the readme. https://github.com/jasonvarga/statamic-runtime-parser-testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch! To test this, I've created two new
If the asset gets incorrectly converted to an array anywhere as it's being passed into the partials (or any other tag or modifier), To help test this, I also created new partials inside
Each partial will output the class name of the expected image. This test case was placed in |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Statamic\Contracts\View\Antlers; | ||
|
||
use Statamic\View\Antlers\AntlersString; | ||
|
||
interface Parser | ||
{ | ||
/** | ||
* Parses the text. | ||
* | ||
* @param string $text Text to parse | ||
* @param array|object $data Array or object to use | ||
* @return AntlersString | ||
*/ | ||
public function parse($text, $data = []); | ||
|
||
/** | ||
* Ignore tags-who-must-not-be-parsed. | ||
* | ||
* @param string $text The text to extract from | ||
* @return string | ||
*/ | ||
public function extractNoparse($text); | ||
|
||
/** | ||
* Sets whether or not PHP code should be evaluated. | ||
* | ||
* @param bool $allow Whether PHP is allowed. | ||
* @return Parser | ||
*/ | ||
public function allowPhp($allow = true); | ||
|
||
/** | ||
* Parses a view file. | ||
* | ||
* @param string $view The view path. | ||
* @param string $text The view contents. | ||
* @param array $data The data. | ||
* @return AntlersString | ||
*/ | ||
public function parseView($view, $text, $data = []); | ||
|
||
/** | ||
* Injects noparse extractions. | ||
* | ||
* This is so that multiple parses can store noparse | ||
* extractions and all noparse can then be injected right | ||
* before data is displayed. | ||
* | ||
* @param string $text Text to inject into | ||
* @return string | ||
*/ | ||
public function injectNoparse($text); | ||
|
||
public function valueWithNoparse($text); | ||
|
||
/** | ||
* Takes a scope-notated key and finds the value for it in the given | ||
* array or object. | ||
* | ||
* @param string $key Dot-notated key to find | ||
* @param array|object $data Array or object to search | ||
* @param mixed $default Default value to use if not found | ||
* @return mixed | ||
*/ | ||
public function getVariable($key, $context, $default = null); | ||
|
||
/** | ||
* Sets a render callback. | ||
* | ||
* @param $callback | ||
* @return Parser | ||
*/ | ||
public function callback($callback); | ||
|
||
public function cascade($cascade); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain when/why you might want to use this? (and the tag/modifier equivalents)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main thinking/driving-force behind that feature was configurable enforcement/restriction of data on sites where there may be many authors. Site administrators can add items to those lists to prevent Control Panel users from using Live Preview on a field with
antlers: true
from getting data they shouldn't be able to, as well as prevent authors from using certain tags/modifiers/variables entirely, separate from the actual template files.