-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmustache.card.js
40 lines (35 loc) · 974 Bytes
/
mustache.card.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
import devboard from '../';
import React from 'react';
var definecard = devboard.ns('5. Mustache demo');
definecard(`
Most of the demos so far have used React, but that isn't required.
This page shows an example of using devboard with mustache templates and jQuery.
`);
import $contactListEditor from "./contactListEditor";
definecard("Editable Contact List",
mustacheCard(
require("./contact-list.tpl.html"),
{
contacts: [
{name: "Glen", email: "[email protected]"},
{name: "Larry", email: "[email protected]"},
{name: "Tim", email: "[email protected]"},
{name: "Jeff", email: "[email protected]"},
{name: "Mark", email: "[email protected]"}
]
},
node => $contactListEditor(node)
)
);
function mustacheCard(template, data, extra) {
return (
<div ref={node => {
if (node) {
node.innerHTML = template(data);
if (extra) {
extra(node);
}
}
}}/>
);
}