From fe5c2eecf9bafa5231a603b7fe84701d77c9572a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 8 May 2016 22:18:22 -0600 Subject: [PATCH] Fix for substitutions passed in via twig function (they need to be in an array) - #574 --- .../partials/modal-remove-package.html.twig | 14 +++++++------- twig/AdminTwigExtension.php | 13 ++++++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/themes/grav/templates/partials/modal-remove-package.html.twig b/themes/grav/templates/partials/modal-remove-package.html.twig index d12f5409..b4f70409 100644 --- a/themes/grav/templates/partials/modal-remove-package.html.twig +++ b/themes/grav/templates/partials/modal-remove-package.html.twig @@ -3,9 +3,9 @@ data-remodal-options="hashTracking: false">
-

{{ "PLUGIN_ADMIN.REMOVE_THE"|tu(("PLUGIN_ADMIN." ~ type|upper)|tu) }}

+

{{ "PLUGIN_ADMIN.REMOVE_THE"|tu([("PLUGIN_ADMIN." ~ type|upper)|tu]) }}

- {{ "PLUGIN_ADMIN.CONFIRM_REMOVAL"|tu(("PLUGIN_ADMIN." ~ type|upper)|tu) }} + {{ "PLUGIN_ADMIN.CONFIRM_REMOVAL"|tu([("PLUGIN_ADMIN." ~ type|upper)|tu]) }}

@@ -15,9 +15,9 @@
\ No newline at end of file +
diff --git a/twig/AdminTwigExtension.php b/twig/AdminTwigExtension.php index 48a90985..c30c5f15 100644 --- a/twig/AdminTwigExtension.php +++ b/twig/AdminTwigExtension.php @@ -45,8 +45,19 @@ class AdminTwigExtension extends \Twig_Extension ]; } - public function tuFilter($args, $lang = null) + public function tuFilter() { + $args = func_get_args(); + $numargs = count($args); + $lang = null; + + if (($numargs == 3 && is_array($args[1])) || ($numargs == 2 && !is_array($args[1]))) { + $lang = array_pop($args); + } elseif ($numargs == 2 && is_array($args[1])) { + $subs = array_pop($args); + $args = array_merge($args, $subs); + } + return $this->grav['admin']->translate($args, $lang); }