• Node.js开发 ---- Jade 模板引擎使用


    1.安装jade插件
    npm install jade

    2.app.js

    var express = require('express'); 
    var http = require('http'); 
    var app = express(); 
    app.set('view engine', 'jade'); // 设置模板引擎 
    app.set('views', __dirname); // 设置模板相对路径(相对当前目录) 
    
    app.get('/', function(req, res) { 
    res.render('test'); // 调用当前路径下的 test.jade 模板 
    }) 
    
    var server = http.createServer(app); 
    server.listen(3002); 
    console.log('server started on http://127.0.0.1:3002/');
    

      

    3.test.jade

    doctype html 
    html 
    title hello,jade 
    body 
    h1 Hello World
    

      

    生成的html文件

    <!DOCtype html> 
    <html> 
    <head> 
    <title>hello,jade</title> 
    </head> 
    
    <body> 
    <h1>Hello World</h1> 
    </body> 
    </html>
    

      

    html转jade
    http://html2jade.vida.io/

    更多:
    http://www.lellansin.com/jade-%E6%A8%A1%E6%9D%BF%E5%BC%95%E6%93%8E%E4%BD%BF%E7%94%A8.html

  • 相关阅读:
    iOS截取长图,自定义截取size
    工作
    UITableView适配iOS11
    利用脚本实现build号自动加一
    iOS原生与JS互调
    CSS高级技巧
    伪元素选择器
    CSS设置过渡
    CSS文本属性 二
    css设置圆角矩形
  • 原文地址:https://www.cnblogs.com/flower1999/p/6322503.html
Copyright © 2020-2023  润新知