-
Hi Is there a way to disable access to control flow (if, else, unless, with, etc.)? For my use case, I need a templating engine that provides efficient keyword replacement ({{ keyword }}) but I don't want users to be able to use control flow statements. Essentially, if the control flow is disabled, then when evaluating the template the engine would ignore the control flow statements.
I couldn't find this on the docs. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can use This will make compilation fail if an unregistered helper is used. Or you can just overwrite existing helpers like this: |
Beta Was this translation helpful? Give feedback.
-
Thank you! This is great |
Beta Was this translation helpful? Give feedback.
You can use
Handlebars.unregisterHelper()
for built-in helpers:https://handlebarsjs.com/playground.html#format=1¤tExample=%7B%22template%22%3A%22%7B%7B%23if%20author%7D%7D%5CnAuthor%3A%20%7B%7BfirstName%7D%7D%20%7B%7BlastName%7D%7D%5Cn%7B%7B%2Fif%7D%7D%22%2C%22partials%22%3A%5B%5D%2C%22input%22%3A%22%7B%5Cn%20%20author%3A%20true%2C%5Cn%20%20firstName%3A%20%5C%22Yehuda%5C%22%2C%5Cn%20%20lastName%3A%20%5C%22Katz%5C%22%2C%5Cn%7D%5Cn%22%2C%22output%22%3A%22Author%3A%20Yehuda%20Katz%5Cn%22%2C%22preparationScript%22%3A%22Handlebars.unregisterHelper('if')%3B%5Cn%22%2C%22handlebarsVersion%22%3A%224.7.7%22%7D
This will make compilation fail if an unregistered helper is used.
Or you can just…