@tivac/mithril-objectify

1.0.0-beta.0 • Public • Published

mithril-objectify

Turn mithril html functions like m(".fooga") into static JS objects like:

{ tag: "div", attrs: { "className" : "fooga" }, children: [ ] }

for speeeeeed.

Use via CLI, API, or as a Browserify transform!

NOTE: This requires iojs/nodejs@0.12.x/nodejs@4.x.x to run, it uses ECMAScript 2015 template strings. Sorry!

Installation

Install with npm

npm i mithril-objectify

Usage

CLI

Accepts an input file and optional output file. No output file will echo the result to stdout.

> mithril-objectify ./input.js
> mithril-objectify ./input.js ./output.js

API

Accepts a string or buffer, returns a buffer.

var objectify = require("mithril-objectify");

console.log(objectify(`m(".fooga.wooga.booga")`);

// logs
// ({ tag: "div", attrs: { className: "fooga wooga booga" }, children: [ ] })

Browserify

Use as a browserify transform, either via the CLI or via code.

CLI

browserify -t mithril-objectify <file>

Code

var build = require("browserify")();

build.transform("mithril-objectify");

b.add("./client.js");

b.bundle().pipe(process.stdout);

Warning

There may be edge cases this doesn't handle well. I'd love to see issues filed w/ repro code for any of them and would be happy to fix them!

Readme

Keywords

none

Package Sidebar

Install

npm i @tivac/mithril-objectify

Weekly Downloads

6

Version

1.0.0-beta.0

License

MIT

Last publish

Collaborators

  • tivac