# {%= name %} {%= badge('npm') %} {%= badge('downloads') %} [![npm total downloads][downloads-img]][downloads-url] > Create [HAST](https://github.com/syntax-tree/hast)-compliant virtual dom trees of HTML using [hyperscript][] compatible syntax or JSX, just in ~570 bytes. [![codeclimate][codeclimate-img]][codeclimate-url] [![codestyle][standard-img]][standard-url] [![linux build][travis-img]][travis-url] [![windows build][appveyor-img]][appveyor-url] [![codecov][coverage-img]][coverage-url] [![dependency status][david-img]][david-url] _You might also be interested in [hyperscript][] - a builder for real dom elements._ **[JSX CodePen Example](http://codepen.io/tunnckoCore/pen/xgQKzr?editors=0010)** ## Highlights - **Tiny:** Very lightweight, ~600 bytes gzip + minify and the UMD wrapper. - **Defaults:** Sane defaults and tiny css selector parser. - **Components:** Can be used to create Stateless or Statefull Components. - **Specificaition:** Creates [HAST](https://github.com/syntax-tree/hast)-compliant AST trees. - **Customization:** Supports [JSX](), custom tags and attributes. - **Minimalist:** Really, just a builder of AST trees. - **Compatibility:** Same as [hyperscript][], but creates virtual DOM. - **Friendly:** Plays well with [browserify][] users. - **Bundled:** Available as ES6 Module, CommonJS, UMD. - **SSR:** Supports server-side rendering through [mich-to-html][]. - **Clean:** Does not mess with DOM or anything. ## Table of Contents ## Install Install with [npm](https://www.npmjs.com/) ``` $ npm install {%= name %} --save ``` or install using [yarn](https://yarnpkg.com) ``` $ yarn add {%= name %} ``` Builds are also available on [unpkg](https://unpkg.com/) CDN, so iniclude ```html ``` then access `mich-h` through the `michH` global property - notice the uppercased **H** letter. ```html ``` **Try [CodePen](http://codepen.io/tunnckoCore/pen/ZLmEyJ) or [JSBin](http://jsbin.com/bahefanasi/2/edit?css,js,output) Example** ## Usage > For more use-cases see the [tests](test.js) ```js const h = require('{%= name %}') const ast = h('div#page.foo.bar.qux', { className: 'ok fool' }, h('#header', h('h1.classy', 'hello', { style: 'background-color: #333; color: purple' })), h('nav#menu', { style: {'background': '#2f2', 'font-size': '12px' } }, h('ul', [ // notice `dataset` and `data-zaz` // both will be set to `properties.dataset` h('li', 'one', { dataset: { foo: 'bar', qux: 'ok' }, 'data-zaz': 'huh' }), h('li.sec', 'two', { className: ['huh'] }), h('li', { 'data-foo': 'hi' }, 'three') ])), h('h2#title', 'content title', { style: {'background-color': 'red'} }), // notice `.first` and `className: 'foobie'` // both will be set in `properties.className` array h('p.first', 'so it is just like a templating engine,\n', { className: 'foobie' }, 'but easy to use inline with javascript', { onclick: () => {} }), h('p', { className: 'lastParagraph' }, 'the intention is for this to be used to create\n', h('strong', 'charlike', { className: ['bold'], style: 'background: white; color: green' }), ' reusable, interactive html widgets.')) console.log(ast) ``` Or with modern JSX syntax, adding [JSX Pragma](https://jasonformat.com/wtf-is-jsx/) somewhere at the top and using some transpiler - Rollup, Webpack or Babel with [babel-plugin-transform-react-jsx][]. ```jsx /** @jsx h */ const h = require('{%= name %}') const onclick = (e) => console.log('hooray it is clicked!') const list =
so it is just like a templating engine, but easy to use inline with javascript
the intention is for this to be used to create charlike reusable, interactive html widgets.
Hello World
console.log(node.properties.style.background) // => 'red' console.log(node.properties.style) // => { background: 'red', 'font-size': '15px' } ``` Notice that we also **don't decamelize** style keys, so you should use quotes. {% if (verb.related && verb.related.list && verb.related.list.length) { %} ## Related {%= related(verb.related.list, {words: 20}) %} {% } %} ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/{%= repository %}/issues/new). Please read the [contributing guidelines](CONTRIBUTING.md) for advice on opening issues, pull requests, and coding standards. If you need some help and can spent some cash, feel free to [contact me at CodeMentor.io](https://www.codementor.io/tunnckocore?utm_source=github&utm_medium=button&utm_term=tunnckocore&utm_campaign=github) too. **In short:** If you want to contribute to that project, please follow these things 1. Please DO NOT edit [README.md](README.md), [CHANGELOG.md](CHANGELOG.md) and [.verb.md](.verb.md) files. See ["Building docs"](#building-docs) section. 2. Ensure anything is okey by installing the dependencies and run the tests. See ["Running tests"](#running-tests) section. 3. Always use `npm run commit` to commit changes instead of `git commit`, because it is interactive and user-friendly. It uses [commitizen][] behind the scenes, which follows Conventional Changelog idealogy. 4. Do NOT bump the version in package.json. For that we use `npm run release`, which is [standard-version][] and follows Conventional Changelog idealogy. Thanks a lot! :) ## Building docs Documentation and that readme is generated using [verb-generate-readme][], which is a [verb][] generator, so you need to install both of them and then run `verb` command like that ``` $ npm install verbose/verb#dev verb-generate-readme --global && verb ``` _Please don't edit the README directly. Any changes to the readme must be made in [.verb.md](.verb.md)._ ## Running tests Clone repository and run the following in that cloned directory ``` $ npm install && npm test ``` ## Author {%= includeEither('authors', 'author') %} + [codementor/tunnckoCore](https://codementor.io/tunnckoCore) ## License {%= copyright({ start: 2016, linkify: true, prefix: 'Copyright', symbol: '©' }) %} {%= licenseStatement %} *** {%= include('footer') %} _Project scaffolded using [charlike][] cli._ {%= reflinks(verb.reflinks) %} [downloads-url]: https://www.npmjs.com/package/{%= name %} [downloads-img]: https://img.shields.io/npm/dt/{%= name %}.svg [codeclimate-url]: https://codeclimate.com/github/{%= repository %} [codeclimate-img]: https://img.shields.io/codeclimate/github/{%= repository %}.svg [travis-url]: https://travis-ci.org/{%= repository %} [travis-img]: https://img.shields.io/travis/{%= repository %}/master.svg?label=linux [appveyor-url]: https://ci.appveyor.com/project/tunnckoCore/{%= name %} [appveyor-img]: https://img.shields.io/appveyor/ci/tunnckoCore/{%= name %}/master.svg?label=windows [coverage-url]: https://codecov.io/gh/{%= repository %} [coverage-img]: https://img.shields.io/codecov/c/github/{%= repository %}/master.svg [david-url]: https://david-dm.org/{%= repository %} [david-img]: https://img.shields.io/david/{%= repository %}.svg [standard-url]: https://github.com/feross/standard [standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg