Skip to content
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

Define syntax of tag names #67

Open
Abscissa opened this issue Apr 20, 2013 · 2 comments
Open

Define syntax of tag names #67

Abscissa opened this issue Apr 20, 2013 · 2 comments
Labels
debate choice that involves preference

Comments

@Abscissa
Copy link

There doesn't appear to be any defined spec for the syntax of tag names. For example: can they include embedded whitespace? Which non-alpha-numeric symbols can/can't they include? Is empty-sting allowed as a name (the syntax does make this possible, but is it allowed)? Etc.

@bobthecow
Copy link
Member

I would read the spec as allowing anything not explicitly disallowed. In fact, whitespace, ->, and all sorts of reserved-looking characters are perfectly valid in identifiers or map keys in many languages. Artificially restricting allowed characters would make things harder for users of those languages to get data into their templates, and would have little benefit.

The only things that a tag name can't contain are . and the closing delimiter (and they can't start with any of the tag sigils — &, =, >, etc — unless they're inside a tag that already has a sigil, so I'd avoid starting with them regardless).

(Quoting myself, from defunkt/pystache#156)

@groue
Copy link

groue commented Aug 27, 2014

@bobthecow is right.

Let's add that white space in tag names should be avoided.

If they were not, spaces surrounding names and spaces inside names would behave differently. Using the dash to show white space:

  • {{foo-bar}} {{-foo-bar-}} {{--foo-bar--}} would be equivalent.
  • {{foo-bar}} {{foo--bar}} would not.

This is a serious enough issue to prevent white space in tag names.

The prevention of tag sigils at the beginning of names is driven by the same concern. A Mustache implementation has to actively prevent users to believe that {{ >name }} is a partial tag, and {{{#name}}}...{{{/name}}} an "unescaped section".

The prevention of dots is required by compound expression such as user.name.

So, the spec is lacking when it does not make all of this explicit. Fortunately, there are years of implementors experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debate choice that involves preference
Projects
None yet
Development

No branches or pull requests

4 participants