From 22d452de82a581c0c71480287c94a48e08c231f9 Mon Sep 17 00:00:00 2001 From: Ville Saarivaara Date: Thu, 2 Nov 2023 10:44:10 +0200 Subject: [PATCH] Pass placeholders for getTemplate --- MarkupMenu.info.json | 2 +- MarkupMenu.module.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/MarkupMenu.info.json b/MarkupMenu.info.json index 8a16f23..de04179 100644 --- a/MarkupMenu.info.json +++ b/MarkupMenu.info.json @@ -1,7 +1,7 @@ { "title": "MarkupMenu", "summary": "MarkupMenu is a module for generating menu markup.", - "version": "1.0.0", + "version": "1.0.1", "author": "Teppo Koivula", "href": "https://github.com/teppokoivula/MarkupMenu", "requires": [ diff --git a/MarkupMenu.module.php b/MarkupMenu.module.php index dd21c99..1b2c832 100644 --- a/MarkupMenu.module.php +++ b/MarkupMenu.module.php @@ -8,7 +8,7 @@ * MarkupMenu is a module for generating menu markup. See README.md for more details. * Some ideas and code in this module are based on the Markup Simple Navigation module. * - * @version 1.0.0 + * @version 1.0.1 * @author Teppo Koivula * @license Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/ */ @@ -425,11 +425,12 @@ protected function getPage($source = null, $default = null): ?Page { * @param string $template_name Template name * @param Page|MarkupMenuData|null $item Item being rendered * @param array $options An array of options + * @param array $placeholders Array of placeholders for string replacements * @return string Template */ - protected function ___getTemplate($template_name, ?WireData $item = null, array $options = []): string { + protected function ___getTemplate($template_name, ?WireData $item = null, array $placeholders = []): string { $template = $options['templates'][$template_name]; - return is_callable($template) ? $template($item, $options) : $template; + return is_callable($template) ? $template($item, $options, $placeholders) : $template; } /** @@ -446,7 +447,7 @@ protected function applyTemplate(string $template_name, array $placeholders, arr $out = ''; - $template = $this->getTemplate($template_name, $item, $options); + $template = $this->getTemplate($template_name, $item, $options, $placeholders); if (!empty($template)) { $placeholders['class'] = $placeholders['classes'][$template_name] ?? $options['classes'][$template_name] ?? null; $placeholders['classes'] = $this->parseClassesString($placeholders, $options, $template_name);