Sha256: 9beb17c3f83d5e7546a6e2ed10872981a804f56e377d3aa3c1d1e61da39d7937
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
sc_require("handlebars"); /** Prepares the Handlebars templating library for use inside SproutCore's view system. The SC.Handlebars object is the standard Handlebars library, extended to use SproutCore's get() method instead of direct property access, which allows computed properties to be used inside templates. To use SC.Handlebars, call SC.Handlebars.compile(). This will return a function that you can call multiple times, with a context object as the first parameter: var template = SC.Handlebars.compile("my {{cool}} template"); var result = template({ cool: "awesome" }); console.log(result); // prints "my awesome template" Note that you won't usually need to use SC.Handlebars yourself. Instead, use SC.TemplateView, which takes care of integration into the view layer for you. */ SC.Handlebars = {}; SC.Handlebars.JavaScriptCompiler = function() {}; SC.Handlebars.JavaScriptCompiler.prototype = SC.beget(Handlebars.JavaScriptCompiler.prototype); SC.Handlebars.JavaScriptCompiler.prototype.compiler = SC.Handlebars.JavaScriptCompiler; SC.Handlebars.JavaScriptCompiler.prototype.nameLookup = function(parent, name, type) { if (type === 'context') { return "SC.get(" + parent + ", " + this.quotedString(name) + ");"; } else { return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(this, parent, name, type); } }; SC.Handlebars.compile = function(string) { var ast = Handlebars.parse(string); var environment = new Handlebars.Compiler().compile(ast); return new SC.Handlebars.JavaScriptCompiler().compile(environment, true); };
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
spade-0.0.1 | sproutcore/frameworks/handlebars/extensions.js |
sproutcore-1.5.0.pre.5 | lib/frameworks/sproutcore/frameworks/handlebars/extensions.js |