New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partials with relative paths can collide #173
Comments
Unfortunately I ran into this issue as well. It doesn't look like this is an issue of the require-handlebars-plugin but rather how Handlebars.js handles its partials. Once you use the > ./partials.html it associates the shorthand of ./partial.html to the absolute path of where that file was found. In order to get around the functionality, if you use RequireJS on your project you can do something like this. -- YOUR PROJECT FILE --
Then farther down when you call your template.... Or you could do your res.render, for my project we needed to have res.write for additional information written later down in the project.
Create a helper, I named mine 'load', and in your Template.html file include the below code to load the partial template.
The 'load' helper needs to be located in your helpers directory (Typcally /templates/helpers). Here is the one I wrote for my project. The 'Template2' would fall in the first If statement, second would fall in the else if. You can enforce wether or not you want to allow strings or only functions passed by removing logic from below. I also have this idea of this._templates in there as well, what you can do in your project is declare a global variable of _template in your define module and set all of your templates there, then pass _templates to your template file, so you have access to all of the templates declared in the _templates object without having to pass every partial to every template.
-- Handlebars Helper --
|
If two different template partials are being used with the same relative path, they collide and one will overwrite the other.
For example:
/example/abc/template.html
with{{> ./partial.html}}
and
/example/def/ghi/template2.html
with{{> ./partial.html}}
The text was updated successfully, but these errors were encountered: