Closed queckezz closed 10 years ago
nice! ill leave some comments inline
awesome, happy to merge with those changes applied. would be sweet to get tests in this PR as well
/cc @swatinem to check it out, it'll remove jade dep
Nice! Don’t forget to mention it in the readme though.
And I must shamefully admit, I haven’t tried the new builder yet. Will it still work on the commandline via component build --use component-jade
?
yeah I will update the readme and add tests tomorrow if I get to it :)
The cli isn't compatible with the newest builder just yet. It shouldn't be hard to implement it again though.
I added tests now, updated the docs and changed the code based on your suggestions. Can you review again? :)
looks good to me! thanks for the awesome pull. i'll fix that typo
hmm, the templates won't actually work if you don't eval
them first though.
https://github.com/segmentio/component-jade/blob/master/examples/template/build.js#L417
maybe add a note in the readme?
Yeah, I guess the problem right now is in the builder: https://github.com/component/builder.js/blob/master/lib/plugins/commonjs.js#L62
Everything that is not json or a js file will get stringified and exported. That means this
var jade = require(\'jade-runtime\');module.exports = function template(locals) {...
gets turned into this
module.exports = "var jade = require(\'jade-runtime\');module.exports = function template(locals) {..."
even though there is already a module.exports
.
yeah. we need an equivalent of the old builder.addFile
and builder.removeFile
(#157) or maybe some kind of filter in the commonjs
plugin
this messed me up too -- couldn't figure out what was going wrong until I saw that the whole thing was stringified.
If #169 gets merged we can use that. In the meantime I'll just use the old builder
I've basically rewrote the module so that it works with @yields changes on the newest builder (0.12.0).
If you would merge this the basic usage will be:
component-jade will compile to plain html if you set
opts.plain
to trueOtherwise it would compile to templates like it did before.
Also, jade and the runtime.js are now not included in the module itself, instead they must be added as dependencies.
If you don't like any of those changes you can simply ignore this PR :) I will add tests and update the readme as soon as it gets accepted.