Answer the question
In order to leave comments, you need to log in
How to use pug?
Good afternoon!
I took up the study of jade ... at first glance, everything is cool and understandable.
But still there are questions.
How to use js in it, like loops, if else?
Now I have such a task in gulp.
gulp.task('jade', function() {
return gulp.src('build/jade/test1.jade')
.pipe(jade({
client: true
})) // pip to jade plugin
.pipe(gulp.dest('dest')); // tell gulp our output folder
});
- var x = 5;
div
ul
- for (var i=1; i<=x; i++) {
li Hello
- }
Answer the question
In order to leave comments, you need to log in
1. Pug is a rebranding of Jade. It was renamed due to a complaint from a non-IT brand of the same name. For work, I would recommend using it. The syntax is the same as in Jade.
2. The code from the tutorial in Pug is compiled. Check if the indentation is correct. Install Linter if you are using Atom/Sublime.
3. For compilation I use the following task in Gulp:
gulp.task('html', function buildHTML() {
return gulp.src('app/pug/*.pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('app'));
});
- development = false
-
css = [
"css/fonts.css",
"css/header.css",
"css/style.css",
];
if development
each item in css
link(rel="stylesheet", href="" + item + "")
else
script(src="css/style.min.js")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question