Mark,
I like to create an object to contain my snippets in a static resource, and then register them all with a quick loop. I think I picked the up from Zach at some point.
Here’s the basic concept:
Your Static Resource
(function (skuid){
//////////////////////////////////////////////
// Shortcuts & Global Variables //
//////////////////////////////////////////////
var $ = skuid.$,
$t = skuid.time,
$m = skuid.model,
mm = $m.Model;
//////////////////////////////////////////////
// Snippets //
//////////////////////////////////////////////
var snippets = {
‘myfirstsnippet’: function (param1, param2) {
// function code
},
‘mycustomfieldrenderer’: function (field, value) {
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field, value);
}
};
//////////////////////////////////////////////
// Register Snippets //
//////////////////////////////////////////////
$.each(snippets,function(name,func){ skuid.snippet.registerSnippet(name,func); });
})(skuid);
Then in the inline snippets on your pages you could call something like this:
skuid.snippet.getSnippet(‘myfirstsnippet’)(x,y);
Or you could simply type “mycustomfieldrenderer” into the snippet field for the custom field renderer.