Registry / serialization / tmodjs

tmodjs

JSON →
library1.0.4jsnpmunverified

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.

npm install tmodjs
INSTALL
IMPORT
SIG · TMODJS
T
tmodjs
serializationjavascriptv1.0.4
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.

template
import template from './path/to/template.js'; var html = template('news/list', data);
const template = require('template.js');
Default format outputs a global `template` function. Ensure the path is relative to your HTML file.
render
const render = require('tpl/build/news/list'); var html = render(data);
const render = require('tpl/build/news/list.html');
When type is cmd/amd/commonjs, each template exports a render function. Require without file extension.
tmod CLI
npx tmod ./tpl --output ./build
npx tmodjs ./tpl --output ./build
The CLI command is `tmod`, not `tmodjs`. Install via npm install -g tmodjs.

Installs TmodJS, creates a template file, compiles it to a single JS bundle, and uses the template function in an HTML page.

npm install -g tmodjs mkdir -p tpl/news cat > tpl/news/list.html <<EOF <ul> {{each list as item}} <li>{{item.title}}</li> {{/each}} </ul> EOF tmod ./tpl --output ./build cat > index.html <<EOF <!DOCTYPE html> <html><body> <div id="list"></div> <script src="build/template.js"></script> <script> var list = [{title:'Item 1'},{title:'Item 2'}]; var html = template('news/list', {list: list}); document.getElementById('list').innerHTML = html; </script> </body></html> EOF
tmod --version
Debug
Known issues
deprecatedTmodJS is no longer maintained. Last release was 2015, last commit 2017. No future updates or security patches.
fix
Migrate to actively maintained alternatives like Handlebars, EJS, or Nunjucks with precompilation.
affects: >=1.0.0
gotchaCLI command is `tmod`, not `tmodjs`. Running `tmodjs` will result in 'command not found'.
fix
Use `tmod` after installing `tmodjs` globally.
affects: *
gotchaTemplate paths used with `template('path/to/template', data)` must not include the file extension.
fix
Use `template('news/list', data)` instead of `template('news/list.html', data)`.
affects: *
gotchaWhen using non-default module types (cmd, amd, commonjs), the output is separate files per template. The require path must not include the template suffix.
fix
Use `require('./path/to/template')` without `.html` extension.
affects: *
deprecatedThe grunt plugin `grunt-tmod` is not actively maintained and may not work with modern Node.js versions.
fix
Use the CLI directly or switch to a modern build tool like Webpack or Vite with a template loader.
affects: >=1.0.0
Errors
Common errors & fixes
bash: tmod: command not found
TmodJS is not installed globally or not in PATH.
fix
Run `npm install -g tmodjs` and verify with `npm list -g tmodjs`.
Error: Cannot find module 'tpl/build/news/list'
Template module path is wrong when using cmd/amd/commonjs type.
fix
Ensure the require path matches the output directory and omits file extension. E.g., `require('./tpl/build/news/list')`.
template is not defined
The compiled template.js file is not loaded or loaded out of order.
fix
Include the script before using `template()`: `<script src="build/template.js"></script>`.
SyntaxError: Unexpected token '<'
Trying to directly load .html template files in Node.js without compilation.
fix
Use TmodJS to precompile templates to JS. Alternatively, use artTemplate's runtime loader but that is deprecated.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
tmodjs — npm install tmodjs · libregistry