Skip to content

Instantly share code, notes, and snippets.

@schovi
Created September 24, 2012 19:32
Show Gist options
  • Save schovi/3777824 to your computer and use it in GitHub Desktop.
Save schovi/3777824 to your computer and use it in GitHub Desktop.
CanJS helper that allows ejs construction like this <div <%= plugin("plugin_name") %> clas="smt">
can.EJS.Helpers.prototype.plugin = function(plugin, params) {
return function(el) {
if(typeof plugin == "string") {
$(el)[plugin](params);
} else {
new plugin(el, params)
}
}
}
@amcdnl
Copy link

amcdnl commented Sep 24, 2012

You should use ...

<%= (el) -> el.my_plugin({ size: "small", labelPos: "none", image: "images/cut.png" }) %>

@schovi
Copy link
Author

schovi commented Dec 23, 2012

Why exactly? This is much cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment