-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Fokke-/master
Pass placeholders for getTemplate
- Loading branch information
Showing
2 changed files
with
6 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/ | ||
*/ | ||
|
@@ -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); | ||
|