Skip to content

Add root context lookup#18

Closed
shootaroo wants to merge 1 commit intoassemble:masterfrom
shootaroo:root-context-lookup
Closed

Add root context lookup#18
shootaroo wants to merge 1 commit intoassemble:masterfrom
shootaroo:root-context-lookup

Conversation

@shootaroo
Copy link

Access to root context in partial by {{root}}.

ex.


---
name: foo
bar:
  name: bar

---
{{name}}
{{> leaf bar}}


leaf.hbs:
{{name}} {{root.name}}

of

foo
bar foo

See handlebars-lang/handlebars.js#525 (comment)

@doowb
Copy link
Member

doowb commented Dec 11, 2013

This looks nice. I'll take a look at it and run it through some assemble tests tomorrow.

Thank you.

@doowb
Copy link
Member

doowb commented Jan 14, 2014

@shootaroo sorry, I lost track of this PR since it's in a repo that we don't have a lot of activity on. I'm testing it today to see how it works out. Thanks again for the PR.

@shootaroo
Copy link
Author

👏

@jonschlinkert
Copy link
Member

@shootaroo
Copy link
Author

@jonschlinkert thanks!
I tried the {{@root}}, but there was a case that does not work.

I'll try to check it whether the case what.

@shootaroo
Copy link
Author

The cause was that options.data is not over the handlebars.compile.

It is all right only the following modifications when applicable the {{@root}}.

-        tmpl = handlebars.compile(tmpl, options);
+        tmpl = handlebars.compile(tmpl, _.defaults({data: true}, options));

@doowb
Copy link
Member

doowb commented Jan 16, 2014

Okay, I see now. I think we can make that change, but we want to leave out the custom name lookup and use the latest handlebars that has @root.

@shootaroo
Copy link
Author

@doowb Is good. I wait for the new release of handlebars.

@doowb
Copy link
Member

doowb commented Mar 17, 2017

Closing since we've updated to Handlebars 4 and we can use the {{@root}} property.

@doowb doowb closed this Mar 17, 2017
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

Successfully merging this pull request may close these issues.

3 participants