ember-template-compiler
Advanced tools
Comparing version 1.7.0 to 1.9.0-alpha
@@ -8,3 +8,3 @@ { | ||
"description": "An npm module for the ember-template-compiler.js file that ships with ember.js", | ||
"version": "1.7.0", | ||
"version": "1.9.0-alpha", | ||
"repository": { | ||
@@ -34,8 +34,8 @@ "type": "git", | ||
"jasmine-node": "~1.11", | ||
"handlebars": "~1" | ||
"handlebars": "~2" | ||
}, | ||
"peerDependencies": { | ||
"handlebars": "~1" | ||
"handlebars": "~2" | ||
}, | ||
"optionalDependencies": {} | ||
} |
@@ -10,3 +10,3 @@ var sut = require('../lib/main'); | ||
it("compiles down a handlebars template", function() { | ||
result = sut.precompile(template).toString(); | ||
result = sut.precompile(template, false); | ||
expect(result).toContain("outlet"); | ||
@@ -13,0 +13,0 @@ }); |
@@ -32,10 +32,9 @@ (function() { | ||
Ember.assert("Ember Handlebars requires Handlebars version 1.0 or 1.1. Include " + | ||
Ember.assert("Ember Handlebars requires Handlebars version 2.0. Include " + | ||
"a SCRIPT tag in the HTML HEAD linking to the Handlebars file " + | ||
"before you link to Ember.", Handlebars); | ||
Ember.assert("Ember Handlebars requires Handlebars version 1.0 or 1.1, " + | ||
"COMPILER_REVISION expected: 4, got: " + Handlebars.COMPILER_REVISION + | ||
" - Please note: Builds of master may have other COMPILER_REVISION values.", | ||
Handlebars.COMPILER_REVISION === 4); | ||
Ember.assert("Ember Handlebars requires Handlebars version 2.0. " + | ||
"Please see more details at http://emberjs.com/blog/2014/10/16/handlebars-update.html.", | ||
Handlebars.COMPILER_REVISION === 6); | ||
@@ -56,3 +55,3 @@ /** | ||
*/ | ||
var EmberHandlebars = Ember.Handlebars = objectCreate(Handlebars); | ||
var EmberHandlebars = Ember.Handlebars = Handlebars.create(); | ||
@@ -100,3 +99,3 @@ /** | ||
```handlebars | ||
{{view App.CalendarView}} | ||
{{view 'calendar'}} | ||
``` | ||
@@ -117,3 +116,4 @@ | ||
Ember.assert("You tried to register a component named '" + name + "', but component names must include a '-'", !Component.detect(value) || name.match(/-/)); | ||
Ember.assert("You tried to register a component named '" + name + | ||
"', but component names must include a '-'", !Component.detect(value) || name.match(/-/)); | ||
@@ -141,3 +141,4 @@ if (View.detect(value)) { | ||
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); | ||
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 EmberHandlebars.helpers.view.call(this, ViewClass, options); | ||
@@ -204,40 +205,2 @@ }; | ||
// Hacks ahead: | ||
// Handlebars presently has a bug where the `blockHelperMissing` hook | ||
// doesn't get passed the name of the missing helper name, but rather | ||
// gets passed the value of that missing helper evaluated on the current | ||
// context, which is most likely `undefined` and totally useless. | ||
// | ||
// So we alter the compiled template function to pass the name of the helper | ||
// instead, as expected. | ||
// | ||
// This can go away once the following is closed: | ||
// https://github.com/wycats/handlebars.js/issues/634 | ||
var DOT_LOOKUP_REGEX = /helpers\.(.*?)\)/, | ||
BRACKET_STRING_LOOKUP_REGEX = /helpers\['(.*?)'/, | ||
INVOCATION_SPLITTING_REGEX = /(.*blockHelperMissing\.call\(.*)(stack[0-9]+)(,.*)/; | ||
EmberHandlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation = function(source) { | ||
var helperInvocation = source[source.length - 1], | ||
helperName = (DOT_LOOKUP_REGEX.exec(helperInvocation) || BRACKET_STRING_LOOKUP_REGEX.exec(helperInvocation))[1], | ||
matches = INVOCATION_SPLITTING_REGEX.exec(helperInvocation); | ||
source[source.length - 1] = matches[1] + "'" + helperName + "'" + matches[3]; | ||
}; | ||
var stringifyBlockHelperMissing = EmberHandlebars.JavaScriptCompiler.stringifyLastBlockHelperMissingInvocation; | ||
var originalBlockValue = EmberHandlebars.JavaScriptCompiler.prototype.blockValue; | ||
EmberHandlebars.JavaScriptCompiler.prototype.blockValue = function() { | ||
originalBlockValue.apply(this, arguments); | ||
stringifyBlockHelperMissing(this.source); | ||
}; | ||
var originalAmbiguousBlockValue = EmberHandlebars.JavaScriptCompiler.prototype.ambiguousBlockValue; | ||
EmberHandlebars.JavaScriptCompiler.prototype.ambiguousBlockValue = function() { | ||
originalAmbiguousBlockValue.apply(this, arguments); | ||
stringifyBlockHelperMissing(this.source); | ||
}; | ||
/** | ||
@@ -277,8 +240,8 @@ Rewrite simple mustaches from `{{foo}}` to `{{bind "foo"}}`. This means that | ||
@static | ||
@param {String} string The template to precompile | ||
@param {String|Object} value The template to precompile or an Handlebars AST | ||
@param {Boolean} asObject optional parameter, defaulting to true, of whether or not the | ||
compiled template should be returned as an Object or a String | ||
*/ | ||
EmberHandlebars.precompile = function(string, asObject) { | ||
var ast = Handlebars.parse(string); | ||
EmberHandlebars.precompile = function(value, asObject) { | ||
var ast = Handlebars.parse(value); | ||
@@ -334,2 +297,2 @@ var options = { | ||
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
13377
246
2