Skip to content

tomek-he-him/mithril-n

Repository files navigation

Travis – build statusCode climateDavid – status of dependenciesCode style: airbnb

n()

Pure DOM nodes in Mithril templates.

Installation

Using bower:

$ bower install mithril-n

Using npm:

$ npm install mithril-n

Usage

It's really just Mithril's m(), which accepts DOM nodes as children as well as original arguments.

So this JavaScript*:

import m from "mithril";
import n from "mithril-n";

m.render(document.body,
  n("home",
    document.createElement("papa"),
    n("mama", m(".son")),
    "A happy family"
  )
);

…will result in:

<home>
  <papa></papa>
  <mama>
    <div class="son"></div>
  </mama>
  A happy family
</home>

* I'm using ES6 syntax here – brought to us today by great projects like babel. When you download a release of mithril-n, you get two versions bundled: one for ES6, one for ES5 (available as CommonJS, RequireJS and as a global variable).

If you're interested in implementation details, have a look at the annotated source.

Contributors

Many thanks to this fine gentleman for his invaluable input:

License

MIT © Tomek Wiszniewski

About

⚡ Pure DOM nodes in Mithril templates.

Resources

License

Stars

Watchers

Forks

Packages

No packages published