application-prototype
Version:
Application builder - prototype
61 lines (58 loc) • 1.62 kB
HTML
<html>
<head>
<script type="text/javascript" charset="utf-8" src="../../../ApplicationPrototype.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../ApplicationBuilder.js"></script>
<meta charset="utf-8">
<title>custom-elements test</title>
</head>
<body>
<mycustomelement js-style="display: {{ data.username ? 'block' : 'none' }}">
Hi {{ data.username }}
{{ console.log(this) || " " }}
</mycustomelement>
<div class="abc">
</div>
</body>
<script type="text/javascript">
var dataSource = {
username : "SomeUser"
};
// using promise to ensure that all modules will load before doing something
new Promise(function(resolve, reject) {
window.App = new ApplicationBuilder();
App.modulePath('../../../constructors');
App.require([
'jsTemplate :: js-template',
]).then(function (a) {
App.bind('jsTemplate', function () {
return a.jsTemplate;
});
resolve(App);
});
}).then(function (App) {
// var node = document.querySelector('mycustomelement');
// node.attrdata.JSrenderer = {
// content : App.jsTemplate().parseContent(node, function () {}, {
// context : node,
// args : {
// data : dataSource
// }
// }),
// attr : App.jsTemplate().parseAttributes(node, function () {}, {
// context : node,
// args : {
// data : dataSource
// }
// })
// };
//
document.querySelector('mycustomelement').renderJs(null, {
data: dataSource
}, function (err, renderer) {
if (!err)
console.log("Rendered ...");
})
});
</script>
</html>