{"id":26576,"library":"utc","title":"utc – Underscore Template Compiler (CLI)","description":"utc is a CLI tool that compiles Underscore.js-style templates into AMD-compatible JavaScript functions. Version 0.1.0 (released 2012) is the only release. It precompiles templates to avoid runtime parsing, suitable for build-time optimization. No active maintenance or updates exist. The tool converts template strings containing <%= ... %> into compiled functions that use with() and concatenated output.","status":"deprecated","version":"0.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/nowamasa/utc","tags":["javascript","AMD","template compiler","underscore"],"install":[{"cmd":"npm install utc","lang":"bash","label":"npm"},{"cmd":"yarn add utc","lang":"bash","label":"yarn"},{"cmd":"pnpm add utc","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"utc is a CLI tool, not a library. No Node.js API is exported.","wrong":"Trying to require('utc') in Node.js code","symbol":"utc CLI","correct":"Run globally: utc -d \"templates\" -s \"Template\" -f \"Str\""}],"quickstart":{"code":"# Install globally\nnpm install -g utc@0.1.0\n\n# Create a template file\necho '(function () {\n    define(function () {\n        return {\n            getListTemplateStr: function () {\n                return this._helper() + \": <%= name %>\";\n            },\n            _helper: function () {\n                return \"hello\";\n            }\n        };\n    });\n}).call(this);' > templates/sampleTemplate.js\n\n# Run the compiler\nutc -d \"templates\" -s \"Template\" -f \"Str\"","lang":"javascript","description":"Shows installation, creating a template file, and compiling it with utc CLI to convert Underscore templates into precompiled functions."},"warnings":[{"fix":"Use modern alternatives like Lodash _.template, handlebars precompilation, or EJS.","message":"Package has not been updated since 2012; no support for modern ECMAScript features or module systems beyond AMD.","severity":"deprecated","affected_versions":"0.1.0"},{"fix":"Copy templates to a build directory first, or use a different build tool that outputs to a separate folder.","message":"CLI modifies files in-place! Use version control or backups before running.","severity":"gotcha","affected_versions":"0.1.0"},{"fix":"Write templates in AMD format or use a wrapper script to convert output.","message":"Only works with AMD-style modules (define). No CommonJS, ES module, or global export support.","severity":"gotcha","affected_versions":"0.1.0"},{"fix":"Use a template engine that avoids with(), like Lodash (with option) or Handlebars.","message":"Uses with(obj) statement in compiled code, which is forbidden in strict mode and may cause performance issues or errors in modern JS environments.","severity":"breaking","affected_versions":"0.1.0"},{"fix":"Wrap in a shell script or npm script to avoid repeated typing.","message":"CLI arguments must exactly match: -d (directory), -s (suffix), -f (function suffix). No configuration file support.","severity":"gotcha","affected_versions":"0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use the global command utc, e.g., from terminal: utc -d ./templates -s Template -f Str","cause":"utc is a CLI tool only; no module exports.","error":"require('utc') is not a function"},{"fix":"Ensure directory exists and file suffix matches: e.g., -s Template looks for *Template.js files.","cause":"The -d directory path does not exist or contains no files matching the suffix.","error":"ENOENT: no such file or directory, open '...'?"},{"fix":"Template must be a function that returns an object with methods containing Underscore template strings.","cause":"Template file does not follow the expected AMD pattern shown in the readme.","error":"TypeError: Cannot read property '1' of null"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}