Skip to content

Instantly share code, notes, and snippets.

@sjmiles
Last active December 15, 2015 12:09
Show Gist options
  • Save sjmiles/5258516 to your computer and use it in GitHub Desktop.
Save sjmiles/5258516 to your computer and use it in GitHub Desktop.
Exploring expectations around template.createInstance
<!DOCTYPE html>
<!--
Copyright 2013 The Toolkitchen Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title></title>
<meta charset="UTF-8">
<script src="../../MDV/src/mdv.js"></script>
</head>
<body>
<template>
<template bind="{{}}">
Hello from {{source}}
</template>
</template>
<!-- -->
<script>
var model = {
source: 'MDV'
};
// does NOT make {{source}} go
// HTMLTemplateElement.bindTree(document.body, model);
//
var t = document.querySelector('template');
var i = t.createInstance();
//
// makes {{source}} go
HTMLTemplateElement.bindTree(i, model);
//
document.body.appendChild(i);
//
// also makes {{source}} go
//HTMLTemplateElement.bindTree(i, model);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment