Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
matchdom
node v8.17.0
version:
master
endpoint
share
tweet
const matchdom = require("matchdom") require("jsdom") require("jsdom-global")() require("dom4") const dom = require("dom-template-strings") let str = "wicked" matchdom(dom`<div id="model" class="[myclass]"> <span>[data.text]</span> </div>`, { myclass: "yes", data: { text: "test" } }).outerHTML
matchdom(dom`<table border="true"> <tr> <td>[list.key|repeat:tr]</td> <td>[list.val|magnet:tr]</td> </tr> </table>`, { list: [{key: 'a', val: 'one'}, {key: 'b', val: 'two'}, {key: 'c'}] }).outerHTML
matchdom(dom`<table border="true"> <tr> <td>[rows.cells.val|repeat:tr|repeat] [some.data]</td> </tr> </table>`, { rows: [ {cells: [{val:'A1'}, {val:'A2'}]}, {cells: [{val:'B1'}, {val:'B2'}]} ], some: { data: "x" } }).outerHTML
matchdom(dom`<div> <a href="/test?toto=1" data-href="?id=[id|url]&status=[status|url]">[title]</a> </div>`, { id: 'xx', title: 'anchor', status: "12" }).outerHTML
Loading…
no comments
sign in
to comment