Closed mmilano closed 7 years ago
per reference in issue 20, a demo test of the issue can be seen here in the test named: Panini variables {{root}} variable that stores a relative path to the root folder: https://github.com/mmilano/panini/tree/testing-root-with-helper
In your test repo, when you write {{> partial-p3 (helper-data)}}
, you're passing in the value of helper-data
as a new child context to the partial-p3
template. That means the root
variable doesn't exist in the partial-p3
template, which is why you get an empty string instead of the ../../
.
However, it's still possible to get to the root
variable. If you write ../root
instead, Handlebars will pull the root
variable out of the parent context. Changing the partial-p3
template to this should do the trick:
<img src="{{../root}}{{filename~}}">
Let me know if that helps :)
ah.
so it appears that i (and maybe some others) misapprehended "root" to be a global sort of value, available everywhere.
it looks like @root.root may work better for me. that seems to work regardless of the level.
thanks, @gakimball.
so it appears that i (and maybe some others) misapprehended "root" to be a global sort of value, available everywhere.
Yeah, it's just how Handlebars works—I don't think there's a concept of global data.
Glad I could help! :)
see issue #20.