Skip to content

support escaping or alternative delimiters when expressions contain literal }} #29

Description

@fykaa

I'm running into a situation where fasttemplate treats any }} inside an expression as the end of that expression, even when the braces are meant to be literal content.

For example:

${{ quote("{{.tag}}") }}

The inner }} is part of the string I want to output, but fasttemplate closes the expression early, which causes an error.
I tried escaping the braces in different ways, but nothing works because tokenizer-level parsing always stops at the first }}.

can also breaks cases like:

${{ {"foo": {"bar": "baz"}} }}

its because the }} inside the JSON object closes the expression too soon.

I just wanted to check :

  • is there an existing workaround for emitting literal }} inside an expression you might be aware of?
  • can we support an alternative pair of start/end delimiters (for example $~~ ... ~~) so users can avoid conflicts when their expressions contain literal braces?
  • or is there a recommended pattern for escaping braces that I might be missing?

thanks a lot for the awesome library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions