hamlc-loader

raw JSON →
0.0.11 verified Sat Apr 25 auth: no javascript deprecated

Webpack loader for Haml-Coffee templates, allowing import of .hamlc files as template functions. Current version 0.0.11. This package is unmaintained since 2016 and relies on deprecated dependencies like haml-coffee. It returns a function that takes locals and renders HTML. No updates in years; not recommended for new projects.

error Module not found: Error: Cannot resolve module 'haml-coffee'
cause Missing dependency haml-coffee not installed.
fix
Run 'npm install haml-coffee --save-dev'
error Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
cause Webpack not configured with hamlc-loader for .hamlc files.
fix
Add { test: /\.hamlc$/, loader: 'hamlc-loader' } to your webpack config.
error TypeError: template is not a function
cause Using ES import syntax 'import' instead of CommonJS 'require'.
fix
Use 'const template = require('./file.hamlc');'
deprecated Package is abandoned; last update 2016. Not compatible with webpack 4+ without modification.
fix Switch to an alternative like haml-loader or migrate to a different template engine.
gotcha Requires haml-coffee as a runtime dependency; it may have incompatible versions or security issues.
fix Ensure haml-coffee is installed and compatible; check for updates or alternatives.
gotcha Must use CommonJS require() in webpack config and modules; ES modules may not work directly.
fix Use require() for .hamlc files in webpack 3 or earlier.
npm install hamlc-loader
yarn add hamlc-loader
pnpm add hamlc-loader

Shows webpack config to load .hamlc files and usage of the template function with locals.

// webpack.config.js
module.exports = {
  module: {
    rules: [
      { test: /\.hamlc$/, loader: 'hamlc-loader' }
    ]
  }
};

// mytemplate.hamlc
.template
  %h1= @title

// app.js
const tmpl = require('./mytemplate.hamlc');
const html = tmpl({ title: 'Hello' });
console.log(html);
// <div class="template">\n  <h1>Hello</h1>\n</div>