You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This works by re-purposing the render() function to register the partials in the HANDLEBARS static variable.
If you can describe your ideal way of fixing this issue, I'd be happy to implement a fix and open a pull request.
The text was updated successfully, but these errors were encountered:
kestred
changed the title
rocket_contrib::handlebar_templates should register partials w/ Handlebars
rocket_contrib::handlebar_templates does not register partials w/ Handlebars
Jan 9, 2017
This isn't following any particular pattern, it is just what is convenient at the time;
Is there a specific place that rocket.rs recognizes for partials?
Indeed. The Handlebars template engine plugin for Rocket is lazy about loading templates. But this clearly indicates that it must be eager. The proper approach is to scan for all of the templates at initialization and register them with handlebars. This is what the Tera engine does, for instance.
This commit improves and changes the templating library in the following ways:
* Templates are now registered/loaded at initialization.
* No synchronization is required to read templates.
* All templates are properly loaded (fixes#122).
* Tera templates are given the proper name: `index`, not `index.html.tera`.
* Rendering tests added for both templating engines.
There is one breaking change:
* Tera templates are given the proper name: `index`, not `index.html.tera`.
Out of the box, Rocket does not correctly handle handlebars partials.
See an example handlebars template:
I currently have a work-around where I write a little hacky-boilerplate before I launch rocket:
This works by re-purposing the
render()
function to register the partials in theHANDLEBARS
static variable.If you can describe your ideal way of fixing this issue, I'd be happy to implement a fix and open a pull request.
The text was updated successfully, but these errors were encountered: