0.1.0 • Published 5 years ago

mrkp v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

MRKP

Create HTML with a single Javascript function.

Isomorphic, works in both the browser and in Node. Only 218 bytes minified.

Install

npm i mrkp

Usage

In node:

var h = require('mrkp')

In the browser:

<script src="/js/mrkp.min.js>
<script>
function h(n,t,e,i){return"<"+(n||"")+((e=Object.keys(e||{}).map(function(n){return!0===e[n]?n:n+'="'+e[n]+'"'})).length?" "+e.join(" "):"")+">"+(t||"")+("string"==typeof i?i:(i||[]).join(""))+(null===t?"":"</"+n+">")}
</script>

Make HTML:

h('div', 'Content', { class: 'active' }, [
  h('ul', '', {}, [
    h('li', 'Meat'),
    h('li', 'Milk'),
    h('li', 'Butter')
  ])
])

MIT Licensed. Enjoy!