Relax dust grammar for supporting spaces #21

Closed
vybs opened this Issue May 2, 2012 · 9 comments

Projects

None yet

4 participants

@vybs
Contributor
vybs commented May 2, 2012

Investigate to alter the dust grammar to support arbitrary space ..

Now Invalid gramar

{#a root1="p1" r2="p2" }

{/a}

Compare the syntax with handle bars or mustache and see how they do it ?

Contributor
rragan commented May 2, 2012

I would vote strongly for such a change. This is such an easy error for a user to make.

@jairodemorais jairodemorais was assigned May 2, 2012
Contributor
vybs commented May 3, 2012

Sure !, looks like it is our top most requested feature here as well ...

So it is our top priority...

Contributor
vybs commented May 4, 2012

Relaxing the grammar to support white spaces.

Jairo and I are working on the above issue for Milestone 3.

Here is the details of the spec:

  1. Allow WS* in the beginning and endinf of the block ? { #a }
  2. Allow WS* between inline params {#a d="r" t="r" }
  3. Allow WS* for self-closing , {#a d="r" t="r" /} and {#a d="r" t="r" / }
  4. Allow WS* for closing, {#a d="r" t="r" } .... { / }

What about other tags ? { > partial / },

Is the consensus to relax it for every tag ? @, ? ^ .....

The same will be ported to the ANTLR as well

Contributor

Mustache parser seems to be in their JS code as regex's https://github.com/defunkt/mustache.js/blob/master/mustache.js
HandleBars uses Jison. Here's the grammar https://github.com/wycats/handlebars.js/blob/master/src/handlebars.yy
Hogan has a compiler.js file https://github.com/twitter/hogan.js/blob/master/lib/compiler.js

Contributor
vybs commented May 5, 2012

@jimmyhchan

@bgaff and eran discussed the same today

We probably wil support the same as in the html

Contributor
vybs commented May 7, 2012

@jimmyhchan

I looked at mustache and its flavors ..

Have u compared Hogan and Handlebars? AFAIK, both added the compiler option, to make mustache rendering fast ...other than that what do they differ with?

Also, looking at the grammar, they do not allow arbitary white spaces as well ..

having said that, it does not mean we should not extend, but we wil now have our own grammar...

Contributor
vybs commented May 7, 2012

@jairodemorais

Here is one proposal...

We follow the html tag standard

  1. Trailing whitespaces allowed

<br / > afsdfs ( Valid tag in html )

So {/skills } and {/ skills } are supported

  1. No spaces between the { and /
    { /skills} not supported
  2. Same hold true for the opening curly brace, no space between the {#skills or {?skills
  3. Same hold true for self closing tags.
Contributor

We are going to follow the W3C recommendation. you can read the spec here: http://www.w3.org/TR/html4

So we aren't going to allow ws immediately after the open tag and before the close tag.

W3C spec extract:

In order to avoid problems with SGML line break rules and inconsistencies among extant implementations, authors should not rely on user agents to render white space immediately after a start tag or immediately before an end tag.

Contributor

fixed and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment