mahal-html-compiler

raw JSON →
1.4.1 verified Fri May 01 auth: no javascript

Official HTML compiler for the Mahal framework (v1.4.1). Transforms Mahal-specific HTML templates into render functions, supporting directives, expressions, and component nesting. Designed exclusively for Mahal's reactive UI system, it is tightly coupled to the framework and not intended for standalone use. Releases are less frequent, tied to Mahal updates. Ships TypeScript types.

error Cannot find module 'mahal-html-compiler' require() of ES Module
cause Using require() instead of import.
fix
Use ES module import syntax.
error TypeError: compile is not a function
cause Incorrect import: default import instead of named import.
fix
Use import { compile } from 'mahal-html-compiler'
breaking Requires Mahal framework >=1.0.0; not backward compatible with older Mahal versions.
fix Ensure your project uses Mahal >=1.0.0.
gotcha Does not support runtime compilation in browser; templates must be precompiled.
fix Precompile templates during build step using Mahal CLI or bundler plugin.
gotcha Errors in template syntax produce cryptic parse errors; no line-level error mapping.
fix Validate templates manually before compilation.
npm install mahal-html-compiler
yarn add mahal-html-compiler
pnpm add mahal-html-compiler

Compiles a simple Mahal template with an interpolation expression.

import { compile } from 'mahal-html-compiler';

const template = '<div>{{ message }}</div>';
const options = { filename: 'App.mahal' };
const result = compile(template, options);
console.log(result.code);