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

AST inconsistency between mustache/partial #1192

Closed
stevenvachon opened this issue Feb 28, 2016 · 1 comment
Closed

AST inconsistency between mustache/partial #1192

stevenvachon opened this issue Feb 28, 2016 · 1 comment

Comments

@stevenvachon
Copy link

{{path}}

parses to

{ type: 'Program',
  body: 
   [ { type: 'MustacheStatement',
       path: 
        { type: 'PathExpression',
          data: false,
          depth: 0,
          parts: [ 'path' ],
          original: 'path',
          loc: 
           SourceLocation {
             source: undefined,
             start: { line: 1, column: 2 },
             end: { line: 1, column: 6 } } },
       params: [],
       hash: undefined,
       escaped: true,
       strip: { open: false, close: false },
       loc: 
        SourceLocation {
          source: undefined,
          start: { line: 1, column: 0 },
          end: { line: 1, column: 8 } } } ],
  strip: {},
  loc: 
   { source: undefined,
     start: { line: 1, column: 0 },
     end: { line: 1, column: 8 } } }

meanwhile

{{> path}}

parses to

{ type: 'Program',
  body: 
   [ { type: 'PartialStatement',
       name: 
        { type: 'PathExpression',
          data: false,
          depth: 0,
          parts: [ 'path' ],
          original: 'path',
          loc: 
           SourceLocation {
             source: undefined,
             start: { line: 1, column: 4 },
             end: { line: 1, column: 8 } } },
       params: [],
       hash: undefined,
       indent: '',
       strip: { open: false, close: false },
       loc: 
        SourceLocation {
          source: undefined,
          start: { line: 1, column: 0 },
          end: { line: 1, column: 10 } } } ],
  strip: {},
  loc: 
   { source: undefined,
     start: { line: 1, column: 0 },
     end: { line: 1, column: 10 } } }

Notice the difference between .body[0].path and .body[0].name. Why have different keys when both use a PathExpression? It forces special casing during interpolation.

@kpdecker
Copy link
Collaborator

These are different because they have different semantics. A partial can have things like partial/name but a path can not, at least not with the same meaning.

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

No branches or pull requests

2 participants