Skip to content

Instantly share code, notes, and snippets.

@jkarsrud
Created May 28, 2013 14:05
Show Gist options
  • Save jkarsrud/5662992 to your computer and use it in GitHub Desktop.
Save jkarsrud/5662992 to your computer and use it in GitHub Desktop.
// Template
Ember.Handlebars.compile("<h1>{{name}}</h1>\n<p>{{content}}</p><ul>{{#each item}}<li>{{item.name}}</li>{{/each}}</ul>")
// Compiled js version
function (context, options) {
options = options || {};
var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
var compilerInfo = container.compilerInfo || [],
compilerRevision = compilerInfo[0] || 1,
currentRevision = Handlebars.COMPILER_REVISION;
if (compilerRevision !== currentRevision) {
if (compilerRevision < currentRevision) {
var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
throw "Template was precompiled with an older version of Handlebars than the current runtime. "+
"Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").";
} else {
// Use the embedded version info since the runtime doesn't know about this revision yet
throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+
"Please update your runtime to a newer version ("+compilerInfo[1]+").";
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment