nodejs基于art-template模板引擎生成
基础核心代码
var template = require('art-template'); var tName = new Date().getTime(); var htmlT = '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title></title></head><body><h1>{{title}}</h1></body></html>'; template(tName, htmlT); var html = template.renderFile(tName, {title: '大家好,我叫小白~'}); console.log("结果: " + html); res.end();
运行结果:
关注下面二维码,订阅更多精彩内容。
![](https://images.cnblogs.com/cnblogs_com/vipstone/848916/o_211225130402_gognzhonghao.jpg)