Skip to content

Instantly share code, notes, and snippets.

@nuysoft
Last active December 31, 2015 22:49
Show Gist options
  • Save nuysoft/8055993 to your computer and use it in GitHub Desktop.
Save nuysoft/8055993 to your computer and use it in GitHub Desktop.
Hyde.js 的双向绑定绑定过程
{
"type": "program",
"statements": [
{
"type": "mustache",
"strip": {
"left": false,
"right": false
},
"escaped": true,
"id": {
"type": "ID",
"original": "title",
"parts": [
"title"
],
"string": "title",
"depth": 0,
"isSimple": true,
"stringModeValue": "title"
},
"params": [],
"eligibleHelper": true
}
],
"strip": {}
}
{
"type": "program",
"statements": [
{
"type": "content",
"string": "<script guid="9" slot="start" type="" path=""
},
{
"type": "mustache",
"strip": {
"left": false,
"right": false
},
"escaped": true,
"id": {
"type": "ID",
"original": "$lastest",
"parts": [
"$lastest"
],
"string": "$lastest",
"depth": 0,
"isSimple": true,
"stringModeValue": "$lastest"
},
"params": [
{
"type": "ID",
"original": "title",
"parts": [
"title"
],
"string": "title",
"depth": 0,
"isSimple": true,
"stringModeValue": "title"
}
],
"eligibleHelper": true,
"isHelper": 1,
"binded": true
},
{
"type": "content",
"string": "" isHelper="false"></script>"
},
{
"type": "mustache",
"strip": {
"left": false,
"right": false
},
"escaped": true,
"id": {
"type": "ID",
"original": "title",
"parts": [
"title"
],
"string": "title",
"depth": 0,
"isSimple": true,
"stringModeValue": "title"
},
"params": [],
"eligibleHelper": true,
"binded": true
},
{
"type": "content",
"string": "<script guid="9" slot="end"></script>"
}
],
"strip": {}
}
<script src="/dist/hyde.js"></script>
<script>
// http://cemerick.github.io/jsdifflib/demo.html
var tpl = '{{title}}'
var ast = Handlebars.parse(tpl)
console.log( JSON.stringify(ast, null, 4) )
AST.handle(ast)
console.log( JSON.stringify(ast, null, 4) )
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment