{"id":26486,"library":"tmodjs","title":"TmodJS","description":"TmodJS (formerly atc) is a front-end template precompilation tool that compiles HTML templates into JavaScript, enabling synchronous file loading in the browser. It supports artTemplate syntax, template organization by directory, and sub-template inclusion. The current stable version is 1.0.4, released in 2015. The project is abandoned; last update was 2017. Key differentiators: precompilation to eliminate runtime template parsing, optional module output in AMD, CMD, CommonJS, or default format, and file watching for incremental builds. Alternatives like Handlebars or EJS with precompilation offer more active maintenance.","status":"abandoned","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/aui/tmodjs","tags":["javascript","template","artTemplate","TemplateJS","CommonJS","RequireJS","SeaJS","AMD","CMD"],"install":[{"cmd":"npm install tmodjs","lang":"bash","label":"npm"},{"cmd":"yarn add tmodjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add tmodjs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default format outputs a global `template` function. Ensure the path is relative to your HTML file.","wrong":"const template = require('template.js');","symbol":"template","correct":"import template from './path/to/template.js';\nvar html = template('news/list', data);"},{"note":"When type is cmd/amd/commonjs, each template exports a render function. Require without file extension.","wrong":"const render = require('tpl/build/news/list.html');","symbol":"render","correct":"const render = require('tpl/build/news/list');\nvar html = render(data);"},{"note":"The CLI command is `tmod`, not `tmodjs`. Install via npm install -g tmodjs.","wrong":"npx tmodjs ./tpl --output ./build","symbol":"tmod CLI","correct":"npx tmod ./tpl --output ./build"}],"quickstart":{"code":"npm install -g tmodjs\nmkdir -p tpl/news\ncat > tpl/news/list.html <<EOF\n<ul>\n{{each list as item}}\n    <li>{{item.title}}</li>\n{{/each}}\n</ul>\nEOF\ntmod ./tpl --output ./build\ncat > index.html <<EOF\n<!DOCTYPE html>\n<html><body>\n<div id=\"list\"></div>\n<script src=\"build/template.js\"></script>\n<script>\nvar list = [{title:'Item 1'},{title:'Item 2'}];\nvar html = template('news/list', {list: list});\ndocument.getElementById('list').innerHTML = html;\n</script>\n</body></html>\nEOF","lang":"javascript","description":"Installs TmodJS, creates a template file, compiles it to a single JS bundle, and uses the template function in an HTML page."},"warnings":[{"fix":"Migrate to actively maintained alternatives like Handlebars, EJS, or Nunjucks with precompilation.","message":"TmodJS is no longer maintained. Last release was 2015, last commit 2017. No future updates or security patches.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use `tmod` after installing `tmodjs` globally.","message":"CLI command is `tmod`, not `tmodjs`. Running `tmodjs` will result in 'command not found'.","severity":"gotcha","affected_versions":"*"},{"fix":"Use `template('news/list', data)` instead of `template('news/list.html', data)`.","message":"Template paths used with `template('path/to/template', data)` must not include the file extension.","severity":"gotcha","affected_versions":"*"},{"fix":"Use `require('./path/to/template')` without `.html` extension.","message":"When using non-default module types (cmd, amd, commonjs), the output is separate files per template. The require path must not include the template suffix.","severity":"gotcha","affected_versions":"*"},{"fix":"Use the CLI directly or switch to a modern build tool like Webpack or Vite with a template loader.","message":"The grunt plugin `grunt-tmod` is not actively maintained and may not work with modern Node.js versions.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install -g tmodjs` and verify with `npm list -g tmodjs`.","cause":"TmodJS is not installed globally or not in PATH.","error":"bash: tmod: command not found"},{"fix":"Ensure the require path matches the output directory and omits file extension. E.g., `require('./tpl/build/news/list')`.","cause":"Template module path is wrong when using cmd/amd/commonjs type.","error":"Error: Cannot find module 'tpl/build/news/list'"},{"fix":"Include the script before using `template()`: `<script src=\"build/template.js\"></script>`.","cause":"The compiled template.js file is not loaded or loaded out of order.","error":"template is not defined"},{"fix":"Use TmodJS to precompile templates to JS. Alternatively, use artTemplate's runtime loader but that is deprecated.","cause":"Trying to directly load .html template files in Node.js without compilation.","error":"SyntaxError: Unexpected token '<'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}