-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not render helper output #26
Labels
Comments
One idea would be to decouple this library from the Mustache library. This would mean quite a bit of changes! |
The other idea would be to overwrite the asRendering() method as follows: diff --git a/src/main/php/com/handlebarsjs/DefaultContext.class.php b/src/main/php/com/handlebarsjs/DefaultContext.class.php
index ae1dfb4..1ea8308 100755
--- a/src/main/php/com/handlebarsjs/DefaultContext.class.php
+++ b/src/main/php/com/handlebarsjs/DefaultContext.class.php
@@ -36,6 +36,24 @@ class DefaultContext extends DataContext {
return new self($result, $parent ?: $this);
}
+ /**
+ * Returns a rendering of a given helper closure
+ *
+ * @param var $closure
+ * @param com.github.mustache.Node $node
+ * @param string[] $options
+ * @param string $start
+ * @param string $end
+ * @return string
+ */
+ public function asRendering($closure, $node, $options= [], $start= '{{', $end= '}}') {
+ $pass= [];
+ foreach ($options as $key => $option) {
+ $pass[$key]= $this->isCallable($option) ? $option($node, $this, $pass) : $option;
+ }
+ return $closure($node, $this, $pass);
+ }
+
/**
* Parse input into segments. Handles literal segments including quoted
* strings, e.g. `input.["item-class"]`. |
thekid
added a commit
that referenced
this issue
Apr 7, 2023
This ensures compatibility with the official Handlebars implementation. See #26
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code produces the output YEHUDA Katz by interpolating the string returned from the helper:
However, the official Handlebars engine does not do this:
This is due to how the Mustache library is implemented. It even has a unittest verifying this behavior.
The text was updated successfully, but these errors were encountered: