Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.

Added support for mustaches beginning with @#98

Closed
amiller-gh wants to merge 2 commits intotildeio:masterfrom
amiller-gh:master
Closed

Added support for mustaches beginning with @#98
amiller-gh wants to merge 2 commits intotildeio:masterfrom
amiller-gh:master

Conversation

@amiller-gh
Copy link
Contributor

Because the handlebars parser treats mustaches beginning with @ differently (see @DaTa variables: http://handlebarsjs.com/reference.html), they do not have the string attribute assigned to them from the ast generated from handlebars. In order to allow other frameworks to support having their own @DaTa variables, modify hydration_opcode.js to accept either string or idName as the mustache identifier.

tl;dr:

  • Mustaches beginning with @ dont have the string attribute defined in the handlebars ast.
  • If a mustache does not have the string attribute present in hydration_opcode.js, use idName instead.
  • Added missing semicolon for element cache in templates.

  - Mustaches begining with @ dont have the string attribute defined in the handlebars ast.
  - If a mustache does not have the string attribute present in hydration_opcode.js, use idName instead.

Added missing semicolin for element cache in templates.
@mixonic
Copy link
Collaborator

mixonic commented Oct 1, 2014

@EpicMiller would definitely want to see some tests here. Not quite sure what role {{@index}} would play in the HTMLBars world, need to consider what this means for real-world APIs. It might be best to fail compilation if someone uses the {{@index}} syntax, just as it might be best to fail on unsupported syntaxes like {{../../someThing}}.

/cc @mmun

@mmun
Copy link
Collaborator

mmun commented Oct 1, 2014

@EpicMiller What's your motivation behind this?

We're planning on implementing something more general than data for HTMLBars (which will likely need support in the Handlebars parser). Check out this RFC: emberjs/rfcs#3.

In the interim we could merge this so that we can at least treat @foo as a regular path instead of a parse error.

@amiller-gh
Copy link
Contributor Author

Commented on the RFC with my thoughts on the larger block params problem, and hopefully with what counts as the motivation behind this. emberjs/rfcs#3

Tests can be added :)

Conflicts:
	packages/htmlbars-compiler/lib/compiler/hydration_opcode.js
@mmun
Copy link
Collaborator

mmun commented Dec 3, 2014

This "just works" with the new Handlebars AST. @foo.bar and foo.bar are both PathExpressions, the first one simply has data: true on it. HTMLBars doesn't implement any special semantics for it though (yet?).

@mmun mmun closed this Dec 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants