Template should not evaluate outside the templating expression marks (eg `{{ }}`) · Issue #723 · configu/configu · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With my previous experience working with templating stuff, the evaluation of values should only happen between {{ }}, and outside the {{ }} should remain untouched/unchanged, however it is not the case in configu.
For example I have a file back-tick.txt, its content is just
`
Run configu eval | configu export --template examples/back-tick.txt it will give
configu eval | configu export --template examples/back-tick.txt
│
◇ Configs evaluated successfully
│
■ template expression evaluation failed: Error: Failed to evaluate expression "````"
│ "" is not a function
which it is expected to just give
`
Currently we need to prepend \ before to give the expected content, which is counter intuitive.
Another example is \n
For example we have a line-break.json
{
"title": "Hello",
"paragraph": "{{$.configs.MESSAGE.value}}\nIt is a nice day"
}
configu eval | configu export --template examples/line-break.json it gives the following, which breaks the json syntax
{
"title": "Hello",
"paragraph": "Hi there!It is a nice day"
}
which I expect it gives the following instead, that does not evaluate the line break character
{
"title": "Hello",
"paragraph": "Hi there!\nIt is a nice day"
}
Now I need to add extra \ to avoid \n being evaluated, which is not supposed to be a templating engine's behavior
{
"title": "Hello",
"paragraph": "{{$.configs.MESSAGE.value}}\\nIt is a nice day"
}
Expected Behavior
it is in above
To Reproduce
No response
Context
No response
The text was updated successfully, but these errors were encountered:
Hi @dipsywong98, you're correct—before v1, this was indeed the behavior. For v1, we considered this extensively and made deliberate choices to maintain backward compatibility with the original {{ }} syntax while introducing a more powerful, JavaScript-based templating language leveraging backticks and ${} literals.
Additionally, we're planning to support other familiar templating syntax styles by introducing multiple configurable delimiters. In the future, you might be able to opt-in or out of specific templating styles via .configu configuration settings, allowing you to select the approach that best fits your needs. However, the default approach is likely to remain JavaScript-based template literals (with backticks and ${}).
In the meantime, escaping literals remains necessary, but this direction ensures maximum flexibility and backward compatibility for diverse use cases.
Current Behavior
With my previous experience working with templating stuff, the evaluation of values should only happen between
{{ }}
, and outside the{{ }}
should remain untouched/unchanged, however it is not the case in configu.For example I have a file
back-tick.txt
, its content is justRun
configu eval | configu export --template examples/back-tick.txt
it will givewhich it is expected to just give
Currently we need to prepend
\
before to give the expected content, which is counter intuitive.Another example is
\n
For example we have a
line-break.json
configu eval | configu export --template examples/line-break.json
it gives the following, which breaks the json syntaxwhich I expect it gives the following instead, that does not evaluate the line break character
Now I need to add extra
\
to avoid\n
being evaluated, which is not supposed to be a templating engine's behaviorExpected Behavior
it is in above
To Reproduce
No response
Context
No response
The text was updated successfully, but these errors were encountered: