Remixml

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

Remixml is an XML/HTML-like macro language and template compiler engine for JavaScript, currently at v7.0.11. It compiles templates directly into minified JavaScript with zero runtime dependencies, supports auto-escaping, asynchronous control, user-defined tags, filters, and whitespace preservation. Unlike many templating engines, Remixml uses XML entities (e.g., &scope.varname;) instead of artificial delimiters, integrates smoothly with existing XHTML/HTML syntax highlighting, and includes a validating XHTML parser. It runs in Node.js (ES2018+) and modern browsers, with a runtime size under 7 KB gzipped.

error Uncaught TypeError: Remixml is not a constructor
cause Attempting to instantiate Remixml with 'new Remixml()' in v7+.
fix
Use static methods: import Remixml from 'remixml'; Remixml.parse2txt(...);
error Error: Entity '._.sitename' not found
cause Variable name does not start with a valid scope prefix (e.g., '_', 'var', 'anything') or data object is missing the scope.
fix
Ensure data object has the scope as a nested object: { _: { sitename: 'value' } }
error Error: Missing closing tag for '<for>'
cause The <for> tag requires a </for> closing tag. Remixml is strict about well-formed XML/XHTML.
fix
Add </for> or self-close the tag if using a different form.
gotcha Variable names must contain at least one dot (e.g., &scope.varname;). Plain ampersand entities like &varname; are treated as HTML entities, not Remixml variables.
fix Use &scope.varname; syntax for all template variables.
gotcha In <for list="...">, the list value must be a string expression resolving to an array; objects are not directly iterable with <for>.
fix Use <for list="&var.items;"> where items is an array. For objects, use RXML library or custom tag.
deprecated The official documentation suggests using entities like &var.arrays.1; for array indexing, but this is fragile and not recommended.
fix Use <set> and <for> loops to access array elements or pass them as data properties.
breaking In v7, the default export changed from a constructor to a plain object with static methods. Old code using 'new Remixml()' will break.
fix Use import Remixml from 'remixml' and call Remixml.parse2txt() directly; do not instantiate.
gotcha Remixml does not escape HTML in variable values by default; you must explicitly use autoescape filters or entity encoding.
fix Use <autoescape>on</autoescape> or apply filters to variables: &escape.htmlescape(var.foo);
npm install remixml
yarn add remixml
pnpm add remixml

Demonstrates basic Remixml usage: parsing a template with variable substitution and a loop.

import Remixml from 'remixml';

const data = {
  _: {
    sitename: 'Example',
    description: 'quick start'
  },
  var: {
    items: ['foo', 'bar', 'baz']
  }
};

const template = `
<h1>&_.sitename; - &_.description;</h1>
<ul><for list="&var.items;">
  <li>&_._value;</li>
</for></ul>
`;

const output = Remixml.parse2txt(template, data);
console.log(output);
// <h1>Example - quick start</h1>
// <ul>
//   <li>foo</li>
//   <li>bar</li>
//   <li>baz</li>
// </ul>