Skip to content

Commit

Permalink
Includes additional twig syntax featires (#1367)
Browse files Browse the repository at this point in the history
"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>
  • Loading branch information
mogsie and JosefBredereck committed Nov 21, 2021
1 parent 7c66f8a commit 1ebcd53
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/engine-twig/lib/engine_twig.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var engine_twig = {
engineFileExtension: '.twig',

// regexes, stored here so they're only compiled once
findPartialsRE: /{%\s*(?:extends|include|embed)\s+('[^']+'|"[^"]+").*?%}/g,
findPartialsRE: /{%[-]?\s*(?:extends|include|embed|from|import|use)\s+('[^']+'|"[^"]+").*?%}/g,
findPartialKeyRE: /"((?:\\.|[^"\\])*)"/,
findListItemsRE:
/({{#( )?)(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
Expand Down

0 comments on commit 1ebcd53

Please sign in to comment.