mustache / spec

The Mustache spec.
MIT License
366 stars 71 forks source link

How should empty tags be treated? #144

Closed agentgt closed 11 months ago

agentgt commented 1 year ago

Consider the case:

{{}}hello{{}}

I found a lot of varying behavior in mustache implementations.

Perhaps it is out of scope for the spec to dictate what happens on empty tags? That being said I do think Wontache's behavior is incorrect regardless.

jgonggrijp commented 1 year ago

Wontache produces the empty string because it interprets the whole template as a single interpolation tag with }}hello{{ as the key. This playground savestate demonstrates it:

{"data":{"text":"{\n    '}}hello{{': 'x'\n}"},"templates":[{"name":"","text":"{{}}hello{{}}"}]}

Not meaning to defend the behavior though, just clarifying.

I see no use in empty tags, so I don't think it needs specifying, but I'll leave this open for a while so different opinions can be heard.

determin1st commented 11 months ago

mine leaves them alone, both the empty and blank names

{{}}hello{{}} => {{}}hello{{}} {{ }}hello{{}} => {{ }}hello{{}}