From b2ae926c5b4043f9564ac504de21cf18cd5b9ac5 Mon Sep 17 00:00:00 2001 From: hadl Date: Sun, 15 Jan 2023 17:26:18 +0100 Subject: [PATCH] fix(engine-twig-php): twig include function syntax not matched by findPartials Closes: #1471 --- packages/engine-twig-php/lib/engine_twig_php.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/engine-twig-php/lib/engine_twig_php.js b/packages/engine-twig-php/lib/engine_twig_php.js index 2dda1ae18..d52a13ebc 100644 --- a/packages/engine-twig-php/lib/engine_twig_php.js +++ b/packages/engine-twig-php/lib/engine_twig_php.js @@ -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: [], /** @@ -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) => {