yox-template-compiler

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

A template compiler for Yox.js, transforming Yox templates into render functions. Version 0.29.0 is the current stable release, with a slow release cadence. It requires yox-common, yox-config, yox-type, and yox-expression-compiler as peer dependencies. Key differentiator: designed specifically for the Yox.js framework, not a general-purpose template engine.

error Cannot find module 'yox-common'
cause Missing peer dependency
fix
npm install yox-common@^0.20.0
error TypeError: compile is not a function
cause Incorrect import: using default import instead of named
fix
Use import { compile } from 'yox-template-compiler'
breaking The compile function returns a different structure in v0.29.0 vs v0.28.x
fix Update code to handle new return shape: render function is now under .code
deprecated compileToString is deprecated since v0.25.0
fix Use compile or compileToFunctions instead
gotcha All peer dependencies must be at the exact versions specified; mismatch causes runtime errors
fix Install exact versions: yox-common@^0.20.0, yox-config@^0.3.0, etc.
gotcha The compiler only works in Node.js; browser usage requires bundling
fix Use a bundler like webpack or Rollup for browser builds
npm install yox-template-compiler
yarn add yox-template-compiler
pnpm add yox-template-compiler

Compiles a simple Yox template string to a render function object.

import { compile } from 'yox-template-compiler';

const template = '<div>{{ message }}</div>';
const result = compile(template);
console.log(result);