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
Can't render partials in sub-directories on level 3 above #122
Comments
I ran into this same issue myself. It turned out to be a really simple fix. I submitted a PR with the fix in place. |
I ran into this issue too, any new progress? |
You can modify function registerPartials in file node_modules\hbs\lib\hbs.js as code below: Instance.prototype.registerPartials = function (directory, done) {
var handlebars = this.handlebars;
var register = function(filepath, done) {
var isValidTemplate = /\.(html|hbs)$/.test(filepath);
if (!isValidTemplate) {
return done(null);
}
fs.readFile(filepath, 'utf8', function(err, data) {
if (!err) {
var ext = path.extname(filepath);
var templateName = path.relative(directory, filepath)
.slice(0, -(ext.length)).replace(/[ -]/g, '_').replace(/\\/g, '/');
handlebars.registerPartial(templateName, data);
}
done(err);
});
};
walk(directory).on('file', function(root, stat, next) {
register(path.join(root, stat.name), next);
}).on('end', done || function() {});
}; it work fine for me. |
@hoanghuu I modified the source, and it woks fine now. But it's not a good idea to modify the module directly. Could author fix the bug? |
Hi everyone, I am working to help on this module now and going though the issues and pull requests. I see there are two pull requests to fix this issue. Neither had any tests, and even then, there was no CI on Windows. I have now setup CI on Windows and just added a test to PR #143 which I will be merging to (finally) get this fixed for you all ❤️ |
Here is directories constructor:
-views
--------partials
-------------app
-------------------home
------------------------list.hbs
-------------smartphone
------------------home
------------------------list.hbs
------------------------focus.hbs
---------index.hbs
in index.hbs:
{{#if focusNews }}
{{> smartphone/home/focus data=focusNews }}
{{/if}}
When render page, my app throw exception not found partial home/focus.
I think you need change the function registerPartials on module.
The text was updated successfully, but these errors were encountered: