Giter Site home page Giter Site logo

nichoth / html2hyperscript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unframework/html2hyperscript

0.0 3.0 0.0 88 KB

Convert legacy HTML to Hyperscript (https://github.com/dominictarr/hyperscript and https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript)

JavaScript 100.00%

html2hyperscript's Introduction

Build Status

Convert Legacy HTML to Hyperscript

Automatically translate old HTML markup into the new Hyperscript markup embeddable directly inside your component Javascript code.

Use this for hand-converting legacy project source code (e.g. AngularJS templates): care is taken to preserve original whitespace and even comments. For dynamic serving and CI builds check out https://github.com/alexmingoia/jsx-transform instead.

npm install -g html2hyperscript
html2hyperscript legacy_markup_file.html > shiny_new_syntax.js

See Hyperscript library: https://github.com/dominictarr/hyperscript

Also useful for virtual DOM Hyperscript-like syntax: https://github.com/Matt-Esch/virtual-dom

HTML goes in:

<table class="sample-html">
  <tr>
    <th>Pandas</th>
    <th>Kittens</th>
    <th>Hedgehogs</th>
  </tr>
  <tr>
    <td>foo</td>
    <td>bar</td>
    <td>baz</td>
  </tr>
  <tr>
    <td>32</td>
    <td>45</td>
    <td>83</td>
  </tr>
  <tr>
    <td>onomatopoeia</td>
    <td>schadenfreude</td>
    <td>antidisestablishmentarianism</td>
  </tr>
</table>

Hyperscript-like JS syntax comes out:

h("table.sample-html", [
  h("tr", [
    h("th", [ "Pandas" ]),
    h("th", [ "Kittens" ]),
    h("th", [ "Hedgehogs" ])
  ]),
  h("tr", [
    h("td", [ "foo" ]),
    h("td", [ "bar" ]),
    h("td", [ "baz" ])
  ]),
  h("tr", [
    h("td", [ "32" ]),
    h("td", [ "45" ]),
    h("td", [ "83" ])
  ]),
  h("tr", [
    h("td", [ "onomatopoeia" ]),
    h("td", [ "schadenfreude" ]),
    h("td", [ "antidisestablishmentarianism" ])
  ])
])

TODO

  • some tests

html2hyperscript's People

Contributors

unframework avatar nichoth avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.