Skip to content

Commit 1ebcd53

Browse files
Includes additional twig syntax featires (#1367)
"from," "import" and "use" are both twig built-in, and uses the same techniques as include, embed etc when resolving template names. Some twig templates use {%- ... -%} syntax that gobble up the whitespace on each side. This change ensures that this syntax is understood when looking for partials. Co-authored-by: Josef Bredreck <13408112+JosefBredereck@users.noreply.github.com>
1 parent 7c66f8a commit 1ebcd53

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/engine-twig/lib/engine_twig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ var engine_twig = {
124124
engineFileExtension: '.twig',
125125

126126
// regexes, stored here so they're only compiled once
127-
findPartialsRE: /{%\s*(?:extends|include|embed)\s+('[^']+'|"[^"]+").*?%}/g,
127+
findPartialsRE: /{%[-]?\s*(?:extends|include|embed|from|import|use)\s+('[^']+'|"[^"]+").*?%}/g,
128128
findPartialKeyRE: /"((?:\\.|[^"\\])*)"/,
129129
findListItemsRE:
130130
/({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, // TODO

0 commit comments

Comments
 (0)