fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.05k stars 242 forks source link

Add escape syntax to variables expansion syntax (`spin-expressions`) #2528

Open lann opened 1 month ago

lann commented 1 month ago

The current Mustache-inspired template syntax has no way of escaping double open quotes ({{).

While no one has complained about this yet (loudly enough for me to hear), we should probably proactively fix this as it would technically introduce a breaking change.

Some options:

Other suggestions welcome.

karthik2804 commented 1 month ago

I believe liquid templates support the {% raw %} {{something}} {% endraw%} syntax.

lann commented 1 month ago

{% raw %}{{ not interpolated }}{% endraw %}

I don't hate it. It's a little odd to introduce "tag" syntax just for raw but at least it's familiar.

itowlson commented 1 month ago

For what it's worth this is mentioned at https://developer.fermyon.com/spin/v2/template-authoring#expression-syntax (we've hit this before).

@lann The "tag" syntax is not only for raw. As far as I know we support all Liquid tags e.g. if, case, for (see e.g. https://shopify.github.io/liquid/tags/control-flow/) -- we have just not had occasion to use them.

lann commented 1 month ago

Sorry, words are hard. This issue is referring just to the runtime config "templating", i.e. what was once called spin-config, is now mostly referred to as spin-variables, and is implemented in spin-expressions. I wasn't thinking about Spin "templates". :neutral_face:

That said, it probably is worth considering how this would interact with spin-templates, which might be an argument against {% raw %} escaping.

itowlson commented 1 month ago

Of course it is. My brain jumped tracks at the mention of Liquid, which of course was given as an example/analogy and did not mean Spin templates. My apologies.