Open tunnckoCore opened 8 years ago
is-template-file package - sounds reasonable to have such thing?
I can't remember if ~/templates
was implemented here as thoroughly as it was in generate
. This is the code generate uses for resolving templates in user home:
app.onLoad(/(^|[\\\/])templates[\\\/]/, function(file, next) {
var userDefined = app.home('templates', file.relative);
if (utils.exists(userDefined)) {
file.contents = fs.readFileSync(userDefined);
} else {
userDefined = app.home('templates', file.basename)
if (utils.exists(userDefined)) {
file.contents = fs.readFileSync(userDefined);
}
}
if (/^templates[\\\/]/.test(file.relative)) {
file.path = path.join(app.cwd, file.basename);
}
next(null, file);
});
So we will be able to skip render cycle if it's not needed
Can you clarify? Wouldn't render already be skipped if the file doesn't exist? lol
Wouldn't render already be skipped if the file doesn't exist? lol
Not sure enough. Should review assemble-render-file
again lol, but yea, maybe.
@jonschlinkert actually index.js#L55-L57 yea it will skip the file. The idea is to skip the stuff before it, options mergin and etc. So if it is not a template file we can just use app.copy
instead of app.src
and app.render
and etc. We will save some time.
it worth, imho.
So if it is not a template file we can just use app.copy instead of app.src and app.render and etc. We will save some time.
How would we differentiate between files that have templates variables that need to be resolved, and files that don't? might be nice to have a convention for this. I think
You can already disable rendering on individual files, I don't think options merging for a few files have any noticeable performance impact. I'm open to suggestions though
actually, i think i have idea. what about when src
reads the contents check for currently used template delims and if exists, set file.data.render to true, otherwise false - then, in the renderfile we should add one more check to the file.isNull if - and it will skip da file. so it will automagically save some times.
sorry for not have formatting, but im on phone now
and to not forget, it should also be overidden if opts.render is given
edit: even if it not make sense to render if file isnt template edit2: nevermind. this issue is for totally other thing
I'm opening this one for me, cuz I'm going to PR this tonight.
Because I have this
CONTRIBUTING.md
file template and need rendering.Actually, is
update
trying to load templates from global~/templates
directory?edit: btw, got the idea for something like
is-template-file
package - sounds reasonable to have such thing? So we will be able to skip render cycle if it's not needed. Maybe streaming plugin.