Skip to content

Instantly share code, notes, and snippets.

@benvinegar
Created December 2, 2010 21:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benvinegar/726057 to your computer and use it in GitHub Desktop.
Save benvinegar/726057 to your computer and use it in GitHub Desktop.
Example custom template tag for jQuery Templates plugin ($.tmpl)
// Relevant jQuery Template source:
// https://github.com/jquery/jquery-tmpl/blob/master/jquery.tmpl.js#L206
// Example usage: {{pretty_datetime some.date.obj}}
$.extend(jQuery.tmpl.tag, {
"pretty_datetime": {
open: "if($notnull_1){_.push(pretty_datetime($1a));}"
}
});
function pretty_datetime(date) {
/* do something to date */
return date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment