ember-template-compiler
Advanced tools
Comparing version 1.5.0 to 1.6.0-beta.1
@@ -8,3 +8,3 @@ { | ||
"description": "An npm module for the ember-template-compiler.js file that ships with ember.js", | ||
"version": "1.5.0", | ||
"version": "1.6.0-beta.1", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
@@ -1,3 +0,1 @@ | ||
(function() { | ||
var Ember = { assert: function() {}, FEATURES: { isEnabled: function() {} } }; | ||
/*! | ||
@@ -10,3 +8,3 @@ * @overview Ember - JavaScript Application Framework | ||
* See https://raw.github.com/emberjs/ember.js/master/LICENSE | ||
* @version 1.5.0 | ||
* @version 1.6.0-beta.1 | ||
*/ | ||
@@ -16,2 +14,3 @@ | ||
(function() { | ||
var Ember = { assert: function() {}, FEATURES: { isEnabled: function() {} } }; | ||
/** | ||
@@ -22,3 +21,8 @@ @module ember | ||
// Eliminate dependency on any Ember to simplify precompilation workflow | ||
// ES6Todo: you'll need to import debugger once debugger is es6'd. | ||
if (typeof Ember.assert === 'undefined') { Ember.assert = function(){}; }; | ||
if (typeof Ember.FEATURES === 'undefined') { Ember.FEATURES = { isEnabled: function(){} }; }; | ||
var objectCreate = Object.create || function(parent) { | ||
@@ -30,2 +34,7 @@ function F() {} | ||
// set up for circular references later | ||
var View, Component; | ||
// ES6Todo: when ember-debug is es6'ed import this. | ||
// var emberAssert = Ember.assert; | ||
var Handlebars = (Ember.imports && Ember.imports.Handlebars) || (this && this.Handlebars); | ||
@@ -59,3 +68,3 @@ if (!Handlebars && typeof require === 'function') { | ||
*/ | ||
Ember.Handlebars = objectCreate(Handlebars); | ||
var EmberHandlebars = Ember.Handlebars = objectCreate(Handlebars); | ||
@@ -115,9 +124,12 @@ /** | ||
*/ | ||
Ember.Handlebars.helper = function(name, value) { | ||
Ember.assert("You tried to register a component named '" + name + "', but component names must include a '-'", !Ember.Component.detect(value) || name.match(/-/)); | ||
EmberHandlebars.helper = function(name, value) { | ||
if (!View) { View = requireModule('ember-views/views/view')['View']; } // ES6TODO: stupid circular dep | ||
if (!Component) { Component = requireModule('ember-views/views/component')['default']; } // ES6TODO: stupid circular dep | ||
if (Ember.View.detect(value)) { | ||
Ember.Handlebars.registerHelper(name, Ember.Handlebars.makeViewHelper(value)); | ||
Ember.assert("You tried to register a component named '" + name + "', but component names must include a '-'", !Component.detect(value) || name.match(/-/)); | ||
if (View.detect(value)) { | ||
EmberHandlebars.registerHelper(name, EmberHandlebars.makeViewHelper(value)); | ||
} else { | ||
Ember.Handlebars.registerBoundHelper.apply(null, arguments); | ||
EmberHandlebars.registerBoundHelper.apply(null, arguments); | ||
} | ||
@@ -137,6 +149,6 @@ }; | ||
*/ | ||
Ember.Handlebars.makeViewHelper = function(ViewClass) { | ||
EmberHandlebars.makeViewHelper = function(ViewClass) { | ||
return function(options) { | ||
Ember.assert("You can only pass attributes (such as name=value) not bare values to a helper for a View found in '" + ViewClass.toString() + "'", arguments.length < 2); | ||
return Ember.Handlebars.helpers.view.call(this, ViewClass, options); | ||
return EmberHandlebars.helpers.view.call(this, ViewClass, options); | ||
}; | ||
@@ -149,3 +161,3 @@ }; | ||
*/ | ||
Ember.Handlebars.helpers = objectCreate(Handlebars.helpers); | ||
EmberHandlebars.helpers = objectCreate(Handlebars.helpers); | ||
@@ -160,10 +172,10 @@ /** | ||
*/ | ||
Ember.Handlebars.Compiler = function() {}; | ||
EmberHandlebars.Compiler = function() {}; | ||
// Handlebars.Compiler doesn't exist in runtime-only | ||
if (Handlebars.Compiler) { | ||
Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); | ||
EmberHandlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); | ||
} | ||
Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler; | ||
EmberHandlebars.Compiler.prototype.compiler = EmberHandlebars.Compiler; | ||
@@ -176,14 +188,14 @@ /** | ||
*/ | ||
Ember.Handlebars.JavaScriptCompiler = function() {}; | ||
EmberHandlebars.JavaScriptCompiler = function() {}; | ||
// Handlebars.JavaScriptCompiler doesn't exist in runtime-only | ||
if (Handlebars.JavaScriptCompiler) { | ||
Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); | ||
Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler; | ||
EmberHandlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); | ||
EmberHandlebars.JavaScriptCompiler.prototype.compiler = EmberHandlebars.JavaScriptCompiler; | ||
} | ||
Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars"; | ||
EmberHandlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars"; | ||
Ember.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function() { | ||
EmberHandlebars.JavaScriptCompiler.prototype.initializeBuffer = function() { | ||
return "''"; | ||
@@ -201,3 +213,3 @@ }; | ||
*/ | ||
Ember.Handlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string) { | ||
EmberHandlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string) { | ||
return "data.buffer.push("+string+");"; | ||
@@ -222,3 +234,3 @@ }; | ||
Ember.Handlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation = function(source) { | ||
EmberHandlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation = function(source) { | ||
var helperInvocation = source[source.length - 1], | ||
@@ -230,6 +242,7 @@ helperName = (DOT_LOOKUP_REGEX.exec(helperInvocation) || BRACKET_STRING_LOOKUP_REGEX.exec(helperInvocation))[1], | ||
}; | ||
var stringifyBlockHelperMissing = Ember.Handlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation; | ||
var originalBlockValue = Ember.Handlebars.JavaScriptCompiler.prototype.blockValue; | ||
Ember.Handlebars.JavaScriptCompiler.prototype.blockValue = function() { | ||
var stringifyBlockHelperMissing = EmberHandlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation; | ||
var originalBlockValue = EmberHandlebars.JavaScriptCompiler.prototype.blockValue; | ||
EmberHandlebars.JavaScriptCompiler.prototype.blockValue = function() { | ||
originalBlockValue.apply(this, arguments); | ||
@@ -239,4 +252,4 @@ stringifyBlockHelperMissing(this.source); | ||
var originalAmbiguousBlockValue = Ember.Handlebars.JavaScriptCompiler.prototype.ambiguousBlockValue; | ||
Ember.Handlebars.JavaScriptCompiler.prototype.ambiguousBlockValue = function() { | ||
var originalAmbiguousBlockValue = EmberHandlebars.JavaScriptCompiler.prototype.ambiguousBlockValue; | ||
EmberHandlebars.JavaScriptCompiler.prototype.ambiguousBlockValue = function() { | ||
originalAmbiguousBlockValue.apply(this, arguments); | ||
@@ -256,3 +269,3 @@ stringifyBlockHelperMissing(this.source); | ||
*/ | ||
Ember.Handlebars.Compiler.prototype.mustache = function(mustache) { | ||
EmberHandlebars.Compiler.prototype.mustache = function(mustache) { | ||
if (!(mustache.params.length || mustache.hash)) { | ||
@@ -282,4 +295,6 @@ var id = new Handlebars.AST.IdNode([{ part: '_triageMustache' }]); | ||
@param {String} string The template to precompile | ||
@param {Boolean} asObject optional parameter, defaulting to true, of whether or not the | ||
compiled template should be returned as an Object or a String | ||
*/ | ||
Ember.Handlebars.precompile = function(string) { | ||
EmberHandlebars.precompile = function(string, asObject) { | ||
var ast = Handlebars.parse(string); | ||
@@ -300,4 +315,6 @@ | ||
var environment = new Ember.Handlebars.Compiler().compile(ast, options); | ||
return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); | ||
asObject = asObject === undefined ? true : asObject; | ||
var environment = new EmberHandlebars.Compiler().compile(ast, options); | ||
return new EmberHandlebars.JavaScriptCompiler().compile(environment, options, undefined, asObject); | ||
}; | ||
@@ -318,9 +335,9 @@ | ||
*/ | ||
Ember.Handlebars.compile = function(string) { | ||
EmberHandlebars.compile = function(string) { | ||
var ast = Handlebars.parse(string); | ||
var options = { data: true, stringParams: true }; | ||
var environment = new Ember.Handlebars.Compiler().compile(ast, options); | ||
var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); | ||
var environment = new EmberHandlebars.Compiler().compile(ast, options); | ||
var templateSpec = new EmberHandlebars.JavaScriptCompiler().compile(environment, options, undefined, true); | ||
var template = Ember.Handlebars.template(templateSpec); | ||
var template = EmberHandlebars.template(templateSpec); | ||
template.isMethod = false; //Make sure we don't wrap templates with ._super | ||
@@ -333,7 +350,5 @@ | ||
})(); | ||
exports.precompile = Ember.Handlebars.precompile; | ||
exports.EmberHandlebars = Ember.Handlebars; | ||
exports.precompile = EmberHandlebars.precompile; | ||
exports.EmberHandlebars = EmberHandlebars; | ||
})(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15526
282
2