{"id":25714,"library":"gulp-underscore-template","title":"gulp-underscore-template","description":"Gulp plugin that compiles Underscore template (`.html`) files into a single CommonJS module. Version 1.0.0 (latest, 2014) – no updates since. Differentiates by providing a Gulp-stream-friendly API for precompiling templates, enabling minification before compilation, and outputting a require-able module. Alternatives exist in more maintained gulp- template plugins (e.g., gulp-template-compile).","status":"deprecated","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git@github.com:rhgb/gulp-underscore-template","tags":["javascript","gulp","underscore","backbone","template","precompile"],"install":[{"cmd":"npm install gulp-underscore-template","lang":"bash","label":"npm"},{"cmd":"yarn add gulp-underscore-template","lang":"bash","label":"yarn"},{"cmd":"pnpm add gulp-underscore-template","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer runtime dependency for compiled template execution","package":"underscore","optional":false}],"imports":[{"note":"ESM default import; CommonJS require also works with default export. Plugin is a function.","wrong":"const template = require('gulp-underscore-template');","symbol":"default","correct":"import template from 'gulp-underscore-template'"},{"note":"Output module uses CommonJS; ESM import requires default interop (module has no default export).","wrong":"import templates from './lib/templates'","symbol":"require('./lib/templates')","correct":"const templates = require('./lib/templates');"},{"note":"Template keys match filenames (with extension removed), but hyphens require bracket notation.","wrong":"const tpl = templates.somePage;","symbol":"templates['some-page']","correct":"const tpl = templates['some-page'];"}],"quickstart":{"code":"var gulp = require('gulp');\nvar concat = require('gulp-concat');\nvar htmlmin = require('gulp-htmlmin');\nvar template = require('gulp-underscore-template');\n\ngulp.task('templates', function() {\n  return gulp.src('./templates/*.html')\n    .pipe(htmlmin({ collapseWhitespace: true, conservativeCollapse: true }))\n    .pipe(template())\n    .pipe(concat('templates.js'))\n    .pipe(gulp.dest('./lib/'));\n});","lang":"javascript","description":"Compiles all HTML templates into a single CommonJS module using gulp pipeline."},"warnings":[{"fix":"Consider using actively maintained alternatives like gulp-template-compile or gulp-angular-templatecache for newer projects.","message":"Package has not been updated since 2014 and is effectively unmaintained.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use bracket notation: templates['file-name'] instead of templates.fileName.","message":"Template filenames are used as keys with extension removed; hyphens are preserved, requiring bracket notation for access.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"In TypeScript, set esModuleInterop: true; otherwise use `const templates = require(...)`.","message":"Output module uses CommonJS `module.exports`, so ESM consumers need a default import interop or enable esModuleInterop.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add .pipe(htmlmin({...})) before .pipe(template()).","message":"Plugin does not minify HTML; user must pipe through htmlmin separately.","severity":"gotcha","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":"Install underscore: npm install underscore --save (must be a runtime dependency in consuming project).","cause":"Missing underscore peer dependency or version mismatch.","error":"TypeError: _.template is not a function"},{"fix":"Run: npm install gulp-underscore-template --save-dev (requires gulp as well).","cause":"Package not installed.","error":"Cannot find module 'gulp-underscore-template'"},{"fix":"Use require() or transpile the output file with Babel/TypeScript.","cause":"Output file uses CommonJS; importing it via ESM without transpilation fails.","error":"SyntaxError: Unexpected token import"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}