2

This seems to be a simple matter and maybe it's solved already, but I'm not sure how to do it. I'd like to keep arbitrary unresolved expressions for later evaluation. Note that I still don't know which expressions are already defined.

For example, suppose I have the expression...

{{source.path}}/mainmenu{{ext}}"

...and the context defines ext as .js, but source.path is still undefined. What I get is/mainmenu.js", but I'd like to get {{source.path}}/mainmenu.js" instead so that I can evaluate {{source.path}} at a later time. HandlebarsConfiguration.UnresolvedBindingFormatter seemed promising, but it doesn't handle the complete original expression. HandlebarsConfiguration.ExpressionNameResolver also didn't help.

So, is it possible to do this at all? Thanks in advance for any help.

3
  • Hi there, handlebars.net author here. At the time of this writing, that's not possible. Suggest you open an issue on Github or, even better, submit a pull request to add it! Commented Jul 27, 2019 at 1:36
  • I've requested the implementation of the "missing" hooks here. In Handlebarsjs we successfully used the "missingHelper" to implement what you need. Commented May 28, 2020 at 10:38
  • Thanks, @sferencik. I've moved to Nunjucks for some time now because I realized I neeed more powerful templates. Good to know that Handlebars is evolving. Commented May 28, 2020 at 14:12

1 Answer 1

1

the easiest way to handle this issue is to set the default value of the variable as a variable name.

{ name: '{{source.path}}', value: some.real.value || '{{source.path}}' }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.