NodeJS学习(三)

art-template模板引擎

  • 在命令行工具中使用 npm install art-template 命令进行下载
  • 使用const template = require(‘art-template‘)引入模板引擎
  • 告诉模板引擎要拼接的数据和模板在哪 const html = template(‘模板路径’, 数据);
  • 使用模板语法告诉模板引擎,模板与数据应该如何进行拼接

模板引擎语法

  • 标准语法: {{数据}}
  • 原始语法:<%=数据 %>