-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmustache.card.js
More file actions
40 lines (35 loc) · 974 Bytes
/
mustache.card.js
File metadata and controls
40 lines (35 loc) · 974 Bytes
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: "glen@stainlessed.co.uk"},
{name: "Larry", email: "larry@google.com"},
{name: "Tim", email: "tim@apple.com"},
{name: "Jeff", email: "jeff@amazon.com"},
{name: "Mark", email: "mark@fb.com"}
]
},
node => $contactListEditor(node)
)
);
function mustacheCard(template, data, extra) {
return (
<div ref={node => {
if (node) {
node.innerHTML = template(data);
if (extra) {
extra(node);
}
}
}}/>
);
}