riot-plain-htmlmin
A small package that extracts HTML from plain-JS Riot tags, passes it through the Riot's HTML compiler and returns a new string with the HTML replaced.
This gives two benefits:
- Minifies HTML right inside of plain-JS tags
- Fixes all of the HTML limitations when working with
riot.tag()
, since your HTML starts to act like if it's a.tag
file.
It will also keep the same line and column of the actual JS code (`function (opts) { ... }`) which might be helpful in some scenarios when needed to keep stack traces in sync with the source file.
Example
Transpiles a file like this one
riot
into
riot
Usage
const src = fs // the entire file // <- The result
Parameters
Accepts 2 parameters:
- src – the source of an entire file
- options – RiotJS options object that passes to the compiler
How it works
Under the hood it just uses Riot's compileHTML
function. Basically, it just
replaces the HTML string with the compiled one