redhataccess / ascii_binder

AsciiBinder is an AsciiDoc-based system for authoring and publishing closely related documentation sets from a single source.
https://asciibinder.net
MIT License
76 stars 39 forks source link

Can variables be passed to sub-templates? #95

Closed bexelbie closed 6 years ago

bexelbie commented 7 years ago

I have _template/page.html.erb it includes via <%= render("_templates/_footer.html.erb") %> a sub-template. That template can not use the images_path.

Is this a jinja limitation or something we can fix?

Fryguy commented 7 years ago

Does it work if you do something like:

<%= render("_templates/_footer.html.erb", :images_path => images_path) %>

Basically, render calls are a lot like function calls...they can only see the context they are given. The page is given a bunch of paths, but those won't trickle down unless you choose to pass them down. Here is an example for how the css_path is passed: https://github.com/redhataccess/ascii_binder/blob/56e5569f04cceade920a1213e65073e17d56b592/templates/_templates/page.html.erb#L13

bexelbie commented 6 years ago

closing. Thank you @Fryguy