Skip to content

Add root context lookup#18

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

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

Conversation

@shootaroo

Copy link
Copy Markdown

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

doowb commented Dec 11, 2013

Copy link
Copy Markdown
Member

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

Thank you.

@doowb

doowb commented Jan 14, 2014

Copy link
Copy Markdown
Member

@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
Copy Markdown
Author

👏

@jonschlinkert

Copy link
Copy Markdown
Member

@shootaroo

Copy link
Copy Markdown
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
Copy Markdown
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

doowb commented Jan 16, 2014

Copy link
Copy Markdown
Member

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
Copy Markdown
Author

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

@doowb

doowb commented Mar 17, 2017

Copy link
Copy Markdown
Member

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