Skip to content

Commit

Permalink
Merge pull request #3 from Fokke-/master
Browse files Browse the repository at this point in the history
Pass placeholders for getTemplate
  • Loading branch information
teppokoivula authored Nov 2, 2023
2 parents 60295be + 22d452d commit 4cdc116
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MarkupMenu.info.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
9 changes: 5 additions & 4 deletions MarkupMenu.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @license Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/
*/
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit 4cdc116

Please sign in to comment.