liaison - <template> reference
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<template id="name-template">
<div>
First: <input type="text" value="{{first}}" />
Last: <input type="text" value="{{last}}" />
</div>
</template>
<template id="my-template">
<div>Manager:</div>
<template ref="name-template" bind="{{manager}}"></template>
<div>Managed:</div>
<template ref="name-template" repeat="{{managed}}"></template>
</template>
CSS
@font-face{
font-family: Helvetica Neue;
src: local("Helvetica Neue Light"), local("HelveticaNeue-Light");
}
template, * [template] {
display: none;
}
body, input {
font-family: Segoe UI, Helvetica Neue, Helvetica, arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
.cell {
width: 16ex;
display: inline-block;
}
JavaScript
require.config({baseUrl: "http://ibm-js.github.io/libraries/master/"});
require(["liaison-build/layer"], function () {
require([
"liaison/wrapper",
"liaison/DOMTreeBindingTarget"
], function (wrapper) {
document.getElementById("my-template").bind("bind", wrapper.wrap({
manager: {first: "Ben", last: "Beckham"},
managed: [
{first: "John", last: "Doe"},
{first: "Anne", last: "Ackerman"}
]
}));
});
});