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

Comments

Projects
None yet
4 participants
@bmomberger-reciprocity
Contributor

bmomberger-reciprocity commented Jan 9, 2013

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

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jan 9, 2013

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@bmomberger-reciprocity

bmomberger-reciprocity Jan 9, 2013

Contributor

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).

Contributor

bmomberger-reciprocity commented Jan 9, 2013

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 10, 2013

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.

Contributor

justinbmeyer commented Jan 10, 2013

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

This comment has been minimized.

Show comment
Hide comment
@andykant

andykant Jan 28, 2013

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. :)

Contributor

andykant commented Jan 28, 2013

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