-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
65 lines (56 loc) · 1.75 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*!
* mich-to-html <https://github.com/tunnckoCore/mich-to-html>
*
* Copyright (c) Charlike Mike Reagent <@tunnckoCore> (https://i.am.charlike.online)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
// const test = require('mukla')
const toHtml = require('./index')
const h = require('mich-h')
// test('mich-to-html', (done) => {
// michToHtml()
// done()
// })
var ast = h('div#page.foo.bar.qux', { className: 'ok fool' },
h('#header', // if tag name is not given, defaults to `div`
h('h1.classy', null, { style: 'background-color: #333; color: purple' })),
h('nav#menu', { style: {'background': '#2f2', 'font-size': '12px' } },
h('ul', [
h('li', 'one', { dataset: { foo: 'bar', set: 'ok' } }),
h('li.sec', 'two', { className: ['huh'] }),
h('li', 'three', { visible: false })
])),
h('h2#title', 'content title', { style: {'background-color': 'red'} }),
h('p.first', // classes of that `p` would be `first, foobie`
{ className: 'foobie' },
"so it's just like a templating engine, ",
"but easy to use inline with javascript",
{ onclick: () => {} }
),
h('p',
{ className: 'lastParagraph' },
"the intention is for this to be used to create ",
h('strong', 'charlike', {
className: ['bold'],
style: 'background: white; color: green'
}),
" reusable, interactive html widgets."))
toHtml(ast)
// console.log(toHtml(ast))
/**
* Example Components
*/
var Foo = function (props) {
return h('user', { name: props.name }, props.children.map(function (child) {
child.properties.last = props.last
return child
}))
}
var foo = h(Foo, {
name: 'Charlike',
last: 'Reagent'
}, h('strong', { visible: true }, 'hello'))
toHtml(foo)
// console.log(toHtml(foo))