{"id":26465,"library":"template-compiler","title":"atc: 前端模板预编译器","description":"atc (Art Template Compiler) 是一款前端模板预编译工具，当前稳定版本 1.2.1，作为 artTemplate 的子项目，它将模板与目录/文件关联，支持 include 语句和文件组织。与普通模板引擎不同，atc 将模板编译为 CMD/AMD 模块，可异步加载，并依赖 SeaJS 或 RequireJS 等加载器。它包含 Windows 批处理版本和 Node.js 版本，支持路径配置和辅助方法处理。主要的前端模板优化部署工具，但项目已不再活跃更新。","status":"deprecated","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/cdc-im/atc","tags":["javascript","template","artTemplate","RequireJS","SeaJS","AMD","CMD"],"install":[{"cmd":"npm install template-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add template-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add template-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"模板引擎运行时依赖（编译后模板可能仍需引擎支持某些特性）","package":"art-template","optional":true},{"reason":"作为 CMD 加载器支持异步模板加载","package":"seajs","optional":true},{"reason":"作为 AMD 加载器支持异步模板加载","package":"requirejs","optional":true}],"imports":[{"note":"atc 主要通过 CLI 使用，无默认导出，但 compiler.js 可被 require 执行","wrong":"const compiler = require('atc/compiler.js')","symbol":"default","correct":"import 'atc/compiler.js'"}],"quickstart":{"code":"# Windows 环境：\ndouble-click compiler.cmd\n\n# Node.js 环境：\ncd ./demo/templates/\nnode compiler.js","lang":"javascript","description":"展示如何使用 atc 编译模板：Windows 双击批处理文件或 Node.js 运行 compiler.js 编译指定目录下的模板文件。"},"warnings":[{"fix":"考虑迁移至其他模板预编译工具或使用原生 ES 模板字符串","message":"项目不再维护，可能不兼容新版本 Node.js 或加载器","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"使用 <%include('./public/header')%> 而非 <%include('./public/header.html')%> 或 <%include('./tmpl-' + type)%>","message":"include 语句路径不能带后缀名且不能动态拼接","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"确保页面已加载 SeaJS 或 RequireJS，并配置好 base 路径","message":"编译后模板依赖 SeaJS 或 RequireJS 进行异步加载，需额外引入","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.2.1':9 'amd':42 'art':4 'arttempl':11,39 'atc':1,3,19 'cmd':43 'cmd/amd':21 'compil':6 'includ':16 'javascript':37 'node.js':32 'requirej':27,40 'seaj':25,41 'templat':5,38 'window':30 '与普通模板引擎不同':18 '主要的前端模板优化部署工具':35 '但项目已不再活跃更新':36 '作为':10 '前端模板预编译器':2 '可异步加载':23 '它包含':29 '它将模板与目录':13 '将模板编译为':20 '并依赖':24 '当前稳定版本':8 '或':26 '批处理版本和':31 '支持':15 '支持路径配置和辅助方法处理':34 '文件关联':14 '是一款前端模板预编译工具':7 '模块':22 '版本':33 '的子项目':12 '等加载器':28 '语句和文件组织':17","created_at":"2026-05-01T13:50:07.321722+00:00","updated_at":"2026-05-01T13:50:07.321722+00:00","problems":[{"fix":"确保 atc 完整下载，包含 lib/beautify.js 文件","cause":"compiler.js 需要 beautify.js 库，但路径不对或文件缺失","error":"Error: Cannot find module './lib/beautify.js'"},{"fix":"检查模板模板语法，确保符合 artTemplate 规范，并正确闭合标签","cause":"模板文件中使用了 atc 不支持的高级 JavaScript 语法或不匹配的引号/括号","error":"SyntaxError: Unexpected token ILLEGAL"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"atc","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/cdc-im/atc","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/template-compiler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}