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

Mustache: only the current context is passed to partials, instead of the full stack. #227

Closed
bmomberger-reciprocity opened this issue Jan 9, 2013 · 4 comments
Milestone

Comments

@bmomberger-reciprocity
Copy link
Contributor

http://jsfiddle.net/TYe6A/

It makes template organization a hassle, since I can't just take a subsection out of template and move it into a partial if it's calling anything up the stack.

I believe this is because when partials are called in can/view/mustache, the value of CONTEXT_STACK.pop() is sent as the object to render. Would it be feasible to send in all of the stack?

@daffl
Copy link
Contributor

daffl commented Jan 9, 2013

I think this behaviour is according to the Mustache spec (Partials section) isn't it?

I think the trick that Handlebars did was not to allow referencing anything up the stack unless you use backtracking paths. Support for backtracking has been filed in #163. I am not sure if Handlebars can backtrack up the stack in a partial though.

@bmomberger-reciprocity
Copy link
Contributor Author

The spec doesn't seem to cover context nesting; it just says that a partial inherits the current context, but it also says the same for a section (which, in CanJS's Mustache, does inherit the stack).

@justinbmeyer
Copy link
Contributor

I think this makes sense if easy to implement.

Sent from my iPhone

On Jan 9, 2013, at 3:06 PM, "Brad (Bradley) Momberger" notifications@github.com wrote:

The spec doesn't seem to cover context nesting; it just says that a partial inherits the current context, but it also says the same for a section (which, in CanJS's Mustache, does inherit the stack).


Reply to this email directly or view it on GitHub.

@andykant
Copy link
Contributor

There is a lot that is specced in the Mustache spec definition files that isn't listed on their site: https://github.com/mustache/spec

Sections are specced to pass contexts, but partials aren't.

Regardless, good idea so I added support. :)

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

4 participants