jade is a haml based on the html template engine, it has been changed to pug
Installation globally npm install jade -g
Create a new folder jade, build a file name suffix .jade of
editing .jade file
jade -P -w index.jade jade under the monitor file changes in folder, which generates html
index.jade file
1 |
DOCTYPE HTML |
jade basic syntax:
1. indent relationship, instead of the previous html hierarchical inclusion relationship, such as a simple static can be expressed as, pay attention to consistent use spaces to indent or tab, do not mix
2. Writing inline level, a: img
3.style属性:div(style={width:”200px”,color:”red”})
4. Use "-" to define a variable, using the "=" to the output variable element;
5 through # {variable} interpolated value corresponding variant
Element attributes 6.html by brackets to the right of the label comprising (by determination may be added)
7. text
by adding the word before the pipe symbol "|" is output as the content allows jade separated by spaces after the html tag label present in the html content label tag number is added by the addition block level present England. ""8. Note: you can enter comments by the double slash
9. circulation
10. Analyzing the statement "if else" case when default
11.mixin wrapper function call, and
12.js writing, css writing
gulp use
gulp is based on the node Web front-end automation tool to achieve development, it can greatly improve development efficiency. You can also do a lot of things gulp
- CSS compression
- Figure compression
- Compile Sass / LESS
- CoffeeScript compiler
- markdown converted to HTML
6. The compressed combined js
Use gulp to compress js
1.在jade同级建立gulp文件夹,再建立gulpfile.js配置文件
2.在gulp路径下安装gulp
sudo npm install gulp
3.获取到压缩的js的模块gulp-uglify和压缩css的模块gulp-minify-css
npm install gulp-uglify –save
npm install gulp-minify-css –save
这样我们gulp文件夹里地package.json配置文件里就会有者两个模块
4.在gulpfile.js里面引入gulp模块
5.在gulpfile.js里面创建压缩任务:下面我们创建两个压缩任务:js和css
创建压缩任务:gulp.task(name, fn) - 定义任务,第一个参数是任务名,第二个参数是任务 内容。
gulp.src(path) - 选择文件,传入参数是文件路径。
gulp.dest(path) - 输出文件
gulp.pipe() - 管道,你可以暂时将 pipe 理解为将操作加入执行队列
6.监听文件修改:
监听文件修改:gulp.task(‘auto’, function () {
// 监听文件修改,当文件被修改则执行 script 任务 gulp.watch(‘js/*.js’, [‘script’])
})
7.终端进入gulp路径下,输入命令:
gulp mytask
gulp auto
就能实时监控app文件夹下的js文件和css文件,当文件内容有变化时,会自动在build文件夹下生成压缩后的文件