Virtual DOM
HTML Helpers

HTML Helpers

html tagged templates

The html function creates a VNode from an HTML string, and makes it easier to write views without hyperscript or JSX. It accepts a tagged HTML string, meaning you can do interpolation like JSX with the ${expression} syntax.

import { render } from 'million';
import { html } from 'million/html';
render(document.body, html`<div>Hello World</div>`);

Tag factories

You can import tag functions to write shorthands for elements. It is a great middle ground if you want that hyperscript style of development but also want to write less code.

import { render } from 'million';
import { div } from 'million/html';
render(document.body, div(['Hello World']));

You can also construct your own reusable custom element factories if you want:

import { render } from 'million';
import { factory } from 'million/html';
const CUSTOM = factory('CUSTOM');
render(document.body, CUSTOM(['Hello World']));