8000 Template should not evaluate outside the templating expression marks (eg `{{ }}`) · Issue #723 · configu/configu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Template should not evaluate outside the templating expression marks (eg {{ }}) #723

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

Open
dipsywong98 opened this issue Mar 11, 2025 · 1 comment
Labels
bug Something isn't working community triage The issue is new and needs to be triaged by a maintainer

Comments

@dipsywong98
Copy link

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 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

@dipsywong98 dipsywong98 added the bug Something isn't working label Mar 11, 2025
@github-actions github-actions bot added triage The issue is new and needs to be triaged by a maintainer community labels Mar 11, 2025
@rannn505
Copy link
Contributor

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.

see #718 (comment) for an example of template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community triage The issue is new and needs to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants
0