浏览代码

Change example to use `script` instead of `textarea`

tags/v1.0.0
Pascal Pfiffner 12 年前
父节点
当前提交
4184761b20
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. +3
    -3
      README.md

+ 3
- 3
README.md 查看文件

@@ -51,16 +51,16 @@ If you need a template for a dynamic part in a static website, you can consider
<html> <html>
<body onload="loadUser"> <body onload="loadUser">
<div id="target">Loading...</div> <div id="target">Loading...</div>
<textarea id="template" style="display:none;">
<script id="template" type="x-tmpl-mustache">
Hello {{ name }}! Hello {{ name }}!
</textarea>
</script>
</body> </body>
</html> </html>
``` ```


```js ```js
function loadUser() { function loadUser() {
var template = $('#template').val();
var template = $('#template').html();
Mustache.parse(template); // optional, speeds up future uses Mustache.parse(template); // optional, speeds up future uses
var rendered = Mustache.render(template, {name: "Luke"}); var rendered = Mustache.render(template, {name: "Luke"});
$('#target').html(rendered); $('#target').html(rendered);


正在加载...
取消
保存