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.
Common errors
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' Warnings
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.
Install
npm install mahal-html-compiler yarn add mahal-html-compiler pnpm add mahal-html-compiler Imports
- compile wrong
const compile = require('mahal-html-compiler').compilecorrectimport { compile } from 'mahal-html-compiler' - MahalHTMLCompiler wrong
import MahalHTMLCompiler from 'mahal-html-compiler'correctimport { MahalHTMLCompiler } from 'mahal-html-compiler' - CompileOptions
import type { CompileOptions } from 'mahal-html-compiler'
Quickstart
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);