Skip to content

Instantly share code, notes, and snippets.

@canonic-epicure
Created February 23, 2011 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canonic-epicure/840974 to your computer and use it in GitHub Desktop.
Save canonic-epicure/840974 to your computer and use it in GitHub Desktop.
// 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