Registry / web-framework / template-compiler

template-compiler

JSON →
library1.2.1jsnpmunverified

atc (Art Template Compiler) 是一款前端模板预编译工具,当前稳定版本 1.2.1,作为 artTemplate 的子项目,它将模板与目录/文件关联,支持 include 语句和文件组织。与普通模板引擎不同,atc 将模板编译为 CMD/AMD 模块,可异步加载,并依赖 SeaJS 或 RequireJS 等加载器。它包含 Windows 批处理版本和 Node.js 版本,支持路径配置和辅助方法处理。主要的前端模板优化部署工具,但项目已不再活跃更新。

npm install template-compiler
INSTALL
IMPORT
SIG · TEMPLATE-COMPILER
T
template-compiler
web-frameworkjavascriptv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import 'atc/compiler.js'
const compiler = require('atc/compiler.js')
atc 主要通过 CLI 使用,无默认导出,但 compiler.js 可被 require 执行

展示如何使用 atc 编译模板:Windows 双击批处理文件或 Node.js 运行 compiler.js 编译指定目录下的模板文件。

# Windows 环境: double-click compiler.cmd # Node.js 环境: cd ./demo/templates/ node compiler.js
atc --version
Debug
Known issues
deprecated项目不再维护,可能不兼容新版本 Node.js 或加载器
fix
考虑迁移至其他模板预编译工具或使用原生 ES 模板字符串
affects: >=1.0.0
gotchainclude 语句路径不能带后缀名且不能动态拼接
fix
使用 <%include('./public/header')%> 而非 <%include('./public/header.html')%> 或 <%include('./tmpl-' + type)%>
affects: >=0.0.0
gotcha编译后模板依赖 SeaJS 或 RequireJS 进行异步加载,需额外引入
fix
确保页面已加载 SeaJS 或 RequireJS,并配置好 base 路径
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module './lib/beautify.js'
compiler.js 需要 beautify.js 库,但路径不对或文件缺失
fix
确保 atc 完整下载,包含 lib/beautify.js 文件
SyntaxError: Unexpected token ILLEGAL
模板文件中使用了 atc 不支持的高级 JavaScript 语法或不匹配的引号/括号
fix
检查模板模板语法,确保符合 artTemplate 规范,并正确闭合标签
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
art-templateoptional模板引擎运行时依赖(编译后模板可能仍需引擎支持某些特性)
seajsoptional作为 CMD 加载器支持异步模板加载
requirejsoptional作为 AMD 加载器支持异步模板加载
Agent activity
6 hits · last 30 days
node
4
OpenAI (training)
1
Resources
template-compiler — npm install template-compiler · libregistry