Created
February 23, 2011 19:19
-
-
Save canonic-epicure/840974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// templates - methods, which returns plain strings | |
// its possible to call the SUPER template | |
Class('SomeClass', { | |
does : Shotenjin.Embed, | |
methods : { | |
render : function () { | |
this.bodyDOM.innerHTML = this.bodyTpl({ hello : 'world' }) | |
}, | |
bodyTpl : { | |
meta : Shotenjin.Method, | |
sources : { | |
/*tj | |
Hello [%= hello %] | |
[% this.SUPER(stash) %] | |
tj*/ | |
} | |
} | |
} | |
}) | |
// templates - methods, which returns DOM elements | |
Class('SomeClass', { | |
does : Shotenjin.Embed, | |
methods : { | |
render : function () { | |
this.bodyDOM.appendChild( | |
this.bodyTpl({ hello : 'world' }) | |
) | |
}, | |
bodyTpl : { | |
meta : Shotenjin.Method.DOM, | |
sources : { | |
/*tj | |
Hello [%= hello %] | |
[% this.SUPER(stash) %] | |
tj*/ | |
} | |
} | |
}, | |
// should be possible to somehow post-process the DOM element from SUPER | |
// template | |
// more sugar? | |
override : { | |
bodyTpl : function (stash) { | |
var res = this.SUPER(stash) | |
query(res, 'div.footer').appendChild('<span>some text</span>') | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment