Skip to content

Commit

Permalink
fix(engine-twig-php): twig include function syntax not matched by fin…
Browse files Browse the repository at this point in the history
…dPartials

Closes: pattern-lab#1471
  • Loading branch information
hadl committed Jan 15, 2023
1 parent cc1a2bd commit b2ae926
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/engine-twig-php/lib/engine_twig_php.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const engine_twig_php = {
engineFileExtension: '.twig',
expandPartials: false,
findPartialsRE:
/{%\s*(?:extends|include|embed)\s+('[^']+'|"[^"]+").*?(with|%}|\s*%})/g,
findPartialKeyRE: /"((?:\\.|[^"\\])*)"|'((?:\\.|[^"\\])*)'/,
/{[%{]\s*.*?(?:extends|include|embed|from|import|use)\(?\s*['"](.+?)['"][\s\S]*?\)?\s*[%}]}/g,
namespaces: [],

/**
Expand Down Expand Up @@ -180,9 +179,7 @@ const engine_twig_php = {
// return it.
findPartial: function (partialString) {
try {
let partial = partialString.match(this.findPartialKeyRE)[0];
partial = partial.replace(/"/g, '');
partial = partial.replace(/'/g, '');
const partial = partialString.replace(this.findPartialsRE, '$1');

// Check if namespaces is not empty.
const selectedNamespace = this.namespaces.filter((namespace) => {
Expand Down

0 comments on commit b2ae926

Please sign in to comment.