{"name":"hyperscript","version":"1.1.1","author":{"url":"http://dominictarr.com","name":"'Dominic Tarr'","email":"dominic.tarr@gmail.com"},"license":"MIT","_id":"hyperscript@1.1.1","maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"homepage":"https://github.com/dominictarr/hyperscript","dist":{"shasum":"3bc2d462ba742115b9155de99bf043f0971c928c","tarball":"http://registry-npm.ywwl.com/hyperscript/download/hyperscript-1.1.1.tgz","integrity":"sha512-BrVJQ/hBkbGBoym2c6dKqDJ02sXYILsY1WEVFHo5lWZ8WkSj5kusKjvBOvigI+YC0HjjFt2r8yWljYPkEFQu5w==","signatures":[{"sig":"MEUCIHLU3LraX9eeA+DJdd9TxNBWIsxsn4oEEwoR5SNqqAq/AiEAznRiSeWWH//ZzqCJOA4E48bUBNwCzRD/Uyxbqq7Htuo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":11051,"noattachment":false,"key":"/hyperscript/-/hyperscript-1.1.1.tgz"},"_from":".","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"repository":{"url":"git://github.com/dominictarr/hyperscript.git","type":"git"},"_npmVersion":"1.2.3","description":"Create HyperText with JavaScript.","directories":{},"dependencies":{"data-set":"~0.2.2","class-list":"~0.1.0","browser-split":"0.0.0"},"devDependencies":{"tape":"~0.2.2","html-element":"~1.1.0"},"readme":"# HyperScript\n\nCreate HyperText with JavaScript, on client or server.\n\n[![testling badge](https://ci.testling.com/dominictarr/hyperscript.png)]\n  (https://ci.testling.com/dominictarr/hyperscript)\n\n[Interactive Demo](http://dominictarr.github.com/hyperscript)\n\nSee also [mercury](https://github.com/Raynos/mercury) is a modular ui\nframework influenced by hyperscript but much more heavily optimized.\n\n## Example\n\n``` js\nvar h = require('hyperscript')\nh('div#page',\n  h('div#header',\n    h('h1.classy', 'h', { style: {'background-color': '#22f'} })),\n  h('div#menu', { style: {'background-color': '#2f2'} },\n    h('ul',\n      h('li', 'one'),\n      h('li', 'two'),\n      h('li', 'three'))),\n    h('h2', 'content title',  { style: {'background-color': '#f22'} }),\n    h('p',\n      \"so it's just like a templating engine,\\n\",\n      \"but easy to use inline with javascript\\n\"),\n    h('p',\n      \"the intension is for this to be used to create\\n\",\n      \"reusable, interactive html widgets. \"))\n```\n\n## on the server\n\nyou can still use hyperscript on the server,\nthe limitation is that events don't make sense any more,\nbut you can use it to generate html:\n\n``` js\nconsole.log(h('h1', 'hello!').outerHTML)\n=> '<h1>hello!</h1>'\n```\n\n## h (tag, attrs, [text?, Elements?,...])\n\nCreate an `HTMLElement`. The first argument must be the tag name, you may use a\nfully qualified tagname for building e.g. XML documents: `h('ns:tag').\n\n### classes & id\n\nIf the tag name is of form `name.class1.class2#id` that is a short cut\nfor setting the class and id.\n\n### default tag name\n\nIf the tag name begins with a class or id, it defaults to a `<div>`.\n\n### Attributes\n\nIf an `{}` object is passed in it will be used to set attributes.\n\n``` js\nvar h = require('hyperscript')\nh('a', {href: 'https://npm.im/hyperscript'}, 'hyperscript')\n```\n\nNote that hyperscript sets properties on the DOM element object, not\nattributes on the HTML element. This makes for better consistency across\nbrowsers and a nicer API for booleans. There are some gotchas, however.\nAttributes such as `colspan` are camel cased to `colSpan`, and `for` on the\nlabel element is `htmlFor` to avoid collision with the language keyword. See the\n[DOM HTML specification](http://www.w3.org/TR/DOM-Level-2-HTML/html.html)\nfor details.\n\n### events\n\nIf an attribute is a function, then it will be registered as an event listener.\n\n``` js\nvar h = require('hyperscript')\nh('a', {href: '#',\n  onclick: function (e) {\n    alert('you are 1,000,000th visitor!')\n    e.preventDefault()\n  }\n}, 'click here to win a prize')\n```\n\n### styles\n\nIf an attribute has a style property, then that will be handled specially.\n\n``` js\nvar h = require('hyperscript')\nh('h1.fun', {style: {'font-family': 'Comic Sans MS'}}, 'Happy Birthday!')\n```\n\nor as a string\n\n``` js\nvar h = require('hyperscript')\nh('h1.fun', {style: 'font-family: Comic Sans MS'}, 'Happy Birthday!')\n```\n\nYou may pass in attributes in multiple positions, it's no problem!\n\n### children - string\n\nIf an argument is a string, a TextNode is created in that position.\n\n### children - HTMLElement\n\nIf a argument is a `Node` (or `HTMLElement`), for example, the return value of a call to `h`\nthats cool too.\n\n### children - null.\n\nThis is just ignored.\n\n### children - Array\n\nEach item in the array is treated like a ordinary child. (string or HTMLElement)\nthis is useful when you want to iterate over an object:\n\n``` js\nvar h = require('hyperscript')\nvar obj = {\n  a: 'Apple',\n  b: 'Banana',\n  c: 'Cherry',\n  d: 'Durian',\n  e: 'Elder Berry'\n}\nh('table',\n  h('tr', h('th', 'letter'), h('th', 'fruit')),\n  Object.keys(obj).map(function (k) {\n    return h('tr',\n      h('th', k),\n      h('td', obj[k])\n    )\n  })\n)\n```\n\n### Cleaning Up\n\nIf you need to clean up a widget created using hyperscript - deregistering all its event handlers and observable listeners, you can use `context()`.\n\n``` js\nvar h = require('hyperscript').context()\nvar o = require('observable')\nvar text = o()\ntext('click here to win a prize')\nh('a', {href: '#',\n  onclick: function (e) {\n    text('you are 1,000,000th visitor!')\n    e.preventDefault()\n  }\n}, text)\n\n// then if you want to remove this widget from the page\n// to cleanup\nh.cleanup()\n\n```\n## Ecosystem\n\n* [html2hscript](https://github.com/twilson63/html2hscript) - Parse HTML into hyperscript\n* [dom2hscript](https://github.com/AkeemMcLennon/dom2hscript) - Frontend library for parsing HTML into hyperscript using the browser's built in parser.\n* [html2hscript.herokuapp.com](http://html2hscript.herokuapp.com/) - Online Tool that converts html snippets to hyperscript\n* [html2hyperscript](https://github.com/unframework/html2hyperscript) - Original commandline utility to convert legacy HTML markup into hyperscript\n* [hyperscript-helpers](https://github.com/ohanhi/hyperscript-helpers) - write `div(h1('hello')` instead of `h('div', h('h1', 'hello'))`\n* [react-hyperscript](https://github.com/mlmorg/react-hyperscript)  - use hyperscript with React.\n\n## License\n\nMIT\n\n\n\n","publish_time":1366550741142,"_cnpm_publish_time":1366550741142,"dist-tags":{"latest":"2.0.2"}}