0.0.6 • Published 8 years ago

riot-plain-htmlmin v0.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

riot-plain-htmlmin

NPM Version Build Status

js-standard-style

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: 1. Minifies HTML right inside of plain-JS tags 2. Fixes all of the HTML limitations when working with riot.tag(), since your HTML starts to act like if it's a .tag file.

Example

Transpiles a file like this one

import riot from 'riot'

riot.tag('my-tag', `
  <div>HTML ...</div>
`, function(opts) {
  // JS ...
})

into

import riot from 'riot'

riot.tag('my-tag', `<div>HTML ...</div>`

 , function(opts) {
  // JS ...
})

Usage

import fs from 'fs'
import minify from 'riot-plain-htmlmin'

const src = fs.readFileSync('my-tag.js', 'utf-8') // the entire file

minify(src, { compact: true }) // <- 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

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago