-
Notifications
You must be signed in to change notification settings - Fork 656
Add HTML Preprocessors (Jade, Haml and Handlebars) #176
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
Conversation
60f74a7 to
3a11991
Compare
|
I don't know |
|
@zckrs I'm not sure I understand your comment. Actually, yeoman still generates the same raw HTML templates even if a HTML preprocessor is choosen. But later, after user has generated the project, he can add *.jade files and they will be compiled automatically to |
|
Right. I need to read full doc of consolidate. |
|
to make it short, consolidate is a nodeJS tool (with a gulp wrapper) that acts as an adapter for many template engine. It allows to use any template engine from gulp using the same code. var consolidate = require("gulp-consolidate");
gulp.src("./src/*.html", { read : false})
.pipe(consolidate("swig", {
msg: "Hello Gulp!"
}))
.pipe(gulp.dest("./dist"));the
To support an additionnal engine, only thing to do is to install the nodeJS related module (for example, npm install jade, or npm install swig). Using gulp-consolidate avoid to use a different gulp module and script for each template engine (gulp-jade, gulp-swig), those modules having differents API. |
|
I'm not so sure it's needed to handle multiple html preprocessor at a time. But I like the idea of putting this in a separate files. In fact I intent to split the build into As you said, rewriting the index.html could be really hard and could also be impossible to maintain. People may ask to have a index.jade someday but I think we'll refuse it. Anyway, great work! 👍 |
|
@Swiip I'll make some manual tests in the morning and tell you when all is OK to merge. |
bbf0232 to
4459f3a
Compare
|
I've tested and fixed some issues. Also added techs entries for Jade, HAML and Handlebars. I think it's ready for merge. |
87d56c6 to
7e21e08
Compare
|
Looks cool but it seems to break on gulp serve and gulp serve:dist I replaced main.html with main.jade the gulp serve serves up a blank page. The serve works fine if i leave it as main.html |
|
Ok.. so main.html is being served I can't see any difference in the page src but the html works and the jade does not. I don't get it. |
|
Ignore the last 2 comments it was a PEBCAK error. The jade was malfromed and the .jumbotron was indented one tab to far. It works great cant wait to see this and the coffee branch get merged in. Thanks for the contribution. |
|
I wanted to focus on the release of the JS Preprocessor but it breaks the merging of your PR sorry. If you can merge, I think it will be the next big feature of the generator! |
|
No problem, I do it now, I have 10 minutes to kill ... Edit: It's a bit longer than a simple rebase, i need to fix some unit tests now. WIP. |
7e21e08 to
65afcc1
Compare
|
@Swiip I did rebase this branch on current master, and it's working properly now. Please note the change in the way npm devDependencies are added to It would be great to improve and generalize this dependency behavior (it can be refactored and generalized to every choices). And also use the same implementation for bower dependencies. I'll create another branch for those changes if you are OK. |
|
I continue the debate here. As you perfectly mentioned it, there is two ways of dealing with options which implies multiple dependencies:
For some times now, we chose to reduce the preparations and add more ifs in the templates. If it's breaking some front end MVC patterns, we thought it's more maintainable to have a quick look at our template files. In fact, I'm even considering totally removing package / version data in the prompts. |
|
I see, i didn't know this has already been discussed. How about adding a small "middleware", called "dependencies.js" to keep both prompts.json and template simples ? This middleware would be responsible to build dependency lists based on prompts choice, and it would be really more readable that templates conditions. If you are OK with this, i can implement the "middleware" in this branch. If you disagree, i'll simply remove all dependencies from prompts and use yeoman templating engine to register them directly. |
|
Interesting suggestion. I'm not a fan either of the Underscore/Lodash template syntax. We could even create a sort of json file which ables us to list dependencies with some kind of additional parameter which would be the prompt value which trigger the dependency... And we could use the same mechanism for Bower. But all of it has to be addressed in another PR. |
|
Ok, so i can start this new PR tomorrow, and i'll rebase this one to keep dependency management in template. |
65afcc1 to
ff2d986
Compare
|
@Swiip Hope it's OK now :) I'll wait this one to be merged before starting the other PR. |
|
That's perfect, thanks :) |
Add HTML Preprocessors (Jade, Haml and Handlebars)
|
Hi. I created a project choosing Jade as the preprocessor. Is there something else I need to do to be able to work with Jade? |
|
Sorry for the dumb question but if I choose to use handlebars with angular, can I use it like server-side handlebars? Like access the variables exported with the angular scope? If so, how? |
|
Nop, you can't. Its preprocessed by Gulp and served statically to Angular. Handlebars is the less useful as it keep the "XML like" syntax. |
|
@sebastialonso Got the same issue. Am i missing something? Do you need to configure preprocessing of jade 2 html? |
|
You need to address them with .html in your code. Angular can't load jade templates. Gulp compile them and angular load standard html. |
This implements HTML preprocessors (template engine).
It supports jade, haml and handlebars through consolidate. Multiple preprocessors can be supported at the same time, it's based on filename extension in
src/apporsrc/components.Still to be done: