ember-handlebars-brunch
Advanced tools
Comparing version 1.0.4 to 1.1.0
{ | ||
"name": "ember-handlebars-brunch", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Adds pre-compiling support for Ember Handlebars templates to Brunch", | ||
@@ -45,3 +45,4 @@ "author": { | ||
"dependencies": { | ||
"coffee-script": "1.6.2" | ||
"coffee-script": "1.6.2", | ||
"handlebars": "~1.0.0" | ||
}, | ||
@@ -48,0 +49,0 @@ "devDependencies": { |
@@ -0,4 +1,6 @@ | ||
[![Build Status](https://travis-ci.org/bartsqueezy/ember-handlebars-brunch.png?branch=master)](https://travis-ci.org/bartsqueezy/ember-handlebars-brunch) | ||
## Ember Handlebars for Brunch | ||
This [Brunch](http://brunch.io/) plugin adds support for pre-compiling [Ember Handlebars](http://emberjs.com/) templates prior to runtime, utilizing the latest and greatest EmberJS build (1.0.0-RC.5). | ||
This [Brunch](http://brunch.io/) plugin adds support for pre-compiling [Ember Handlebars](http://emberjs.com/) templates prior to runtime, utilizing the latest and greatest EmberJS build (1.0.0). | ||
@@ -9,5 +11,5 @@ It is included by default in the [Ember Brunch](https://github.com/icholy/ember-brunch) skeleton. However if you would like to import it into your own custom Brunch project, the instructions below will get you up and running. | ||
Add `"ember-handlebars-brunch": "git+ssh://git@github.com:bartsqueezy/ember-handlebars-brunch.git"` to `package.json` of your Brunch application. | ||
Add `"ember-handlebars-brunch": "1.0.0"` to `package.json` within your Brunch application codebase. | ||
Within `config.coffee`, set `precompile: true` within the templates compiler if you want to enable pre-compiling. | ||
Within the templates compiler config object of the `config.coffee` file, set `precompile: true` to enable pre-compiling. | ||
@@ -25,3 +27,3 @@ ```coffeescript | ||
1. Make sure the extension of each template file matches the `defaultExtension` property | ||
2. The value you provide for `root` should represent a directory located under your `app` directory. If you do not provide a value for this property, ember-handlebars-brunch will, by default, set the template name to the path of your file, starting from `app`. For instance, without defining the `root` property, a template located at `app/templates/index.hbs` will be registered with Ember like `Ember.TEMPLATES['app/templates/index']`. | ||
2. The value you provide for `root` should represent a directory located under your `app` directory. If you do not provide a value for this property, ember-handlebars-brunch will, by default, set the template name to the path of your file, starting from `app`. For instance, without defining the `root` property, a template located at `app/templates/index.hbs` will be registered with Ember as `Ember.TEMPLATES['app/templates/index']`. | ||
@@ -63,3 +65,3 @@ If using the exact example configuration above, your `views` and `templates` directories should look similar to this: | ||
The precompiled templates are injected into the `Ember.TEMPLATES` namespace. You can access them like so: | ||
The precompiled templates are injected into the `Ember.TEMPLATES` namespace. You can access them within your JS code like so: | ||
@@ -70,6 +72,8 @@ ```javascript | ||
If you wish to `require` the template manually instead of using them directly within a view class, you have to use the full path to the file, starting from the templates directory; | ||
If you wish to `require` the template instead of declaring them directly within a view class or within your code as mentioned above, you have to use the full path to the file, starting from the templates directory; | ||
```javascript | ||
require('templates/index/login'); | ||
``` | ||
``` | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bartsqueezy/ember-handlebars-brunch/trend.png)](https://bitdeli.com/free "Bitdeli Badge") |
@@ -7,3 +7,12 @@ var Handlebars = require('handlebars'); | ||
beforeEach(function() { | ||
plugin = new Plugin({}); | ||
plugin = new Plugin({ | ||
files: { | ||
templates: { | ||
precompile: true | ||
} | ||
}, | ||
modules: { | ||
wrapper: false | ||
} | ||
}); | ||
}); | ||
@@ -20,8 +29,8 @@ | ||
it('should compile and produce valid result', function(done) { | ||
var content = '<strong>{{weak}}</strong>'; | ||
var expected = '<strong>wat</strong>'; | ||
var content = '<strong>{{outlet}}</strong>'; | ||
plugin.compile(content, 'template.handlebars', function(error, data) { | ||
plugin.compile(content, 'foo.handlebars', function(error, data) { | ||
expect(error).not.to.be.ok(); | ||
expect(eval(data)({weak: 'wat'})).to.equal(expected); | ||
expect(data).to.contain('outlet'); | ||
expect(data).to.contain("Ember.TEMPLATES['foo']"); | ||
done(); | ||
@@ -28,0 +37,0 @@ }); |
(function() { | ||
var Ember = { assert: function() {} }; | ||
// Version: v1.0.0-rc.5-30-gc5ea0e2 | ||
// Last commit: c5ea0e2 (2013-06-05 19:59:58 -0700) | ||
var Ember = { assert: function() {}, FEATURES: { isEnabled: function() {} } }; | ||
// Version: 1.1.0 | ||
(function() { | ||
@@ -21,8 +19,8 @@ /** | ||
var Handlebars = this.Handlebars || (Ember.imports && Ember.imports.Handlebars); | ||
if(!Handlebars && typeof require === 'function') { | ||
if (!Handlebars && typeof require === 'function') { | ||
Handlebars = require('handlebars'); | ||
} | ||
Ember.assert("Ember Handlebars requires Handlebars version 1.0.0-rc.4. 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.0-rc.4, COMPILER_REVISION expected: 3, got: " + Handlebars.COMPILER_REVISION + " – Please note: Builds of master may have other COMPILER_REVISION values.", Handlebars.COMPILER_REVISION === 3); | ||
Ember.assert("Ember Handlebars requires Handlebars version 1.0.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.0, COMPILER_REVISION expected: 4, got: " + Handlebars.COMPILER_REVISION + " - Please note: Builds of master may have other COMPILER_REVISION values.", Handlebars.COMPILER_REVISION === 4); | ||
@@ -45,16 +43,2 @@ /** | ||
function makeBindings(options) { | ||
var hash = options.hash, | ||
hashType = options.hashTypes; | ||
for (var prop in hash) { | ||
if (hashType[prop] === 'ID') { | ||
hash[prop + 'Binding'] = hash[prop]; | ||
hashType[prop + 'Binding'] = 'STRING'; | ||
delete hash[prop]; | ||
delete hashType[prop]; | ||
} | ||
} | ||
} | ||
/** | ||
@@ -85,3 +69,3 @@ Register a bound helper or custom view helper. | ||
Assuming a view subclass named `App.CalenderView` were defined, a helper | ||
Assuming a view subclass named `App.CalendarView` were defined, a helper | ||
for rendering instances of this view could be registered as follows: | ||
@@ -115,6 +99,7 @@ | ||
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(/-/)); | ||
if (Ember.View.detect(value)) { | ||
Ember.Handlebars.registerHelper(name, function(options) { | ||
Ember.assert("You can only pass attributes as parameters (not values) to a application-defined helper", arguments.length < 2); | ||
makeBindings(options); | ||
Ember.assert("You can only pass attributes (such as name=value) not bare values to a helper for a View", arguments.length < 2); | ||
return Ember.Handlebars.helpers.view.call(this, value, options); | ||
@@ -125,3 +110,3 @@ }); | ||
} | ||
} | ||
}; | ||
@@ -168,3 +153,2 @@ /** | ||
Ember.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function() { | ||
@@ -208,3 +192,3 @@ return "''"; | ||
} else { | ||
var id = new Handlebars.AST.IdNode(['_triageMustache']); | ||
var id = new Handlebars.AST.IdNode([{ part: '_triageMustache' }]); | ||
@@ -214,3 +198,3 @@ // Update the mustache node to include a hash value indicating whether the original node | ||
// changes and we need to re-render the value. | ||
if(!mustache.escaped) { | ||
if (!mustache.escaped) { | ||
mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]); | ||
@@ -273,3 +257,6 @@ mustache.hash.pairs.push(["unescaped", new Handlebars.AST.StringNode("true")]); | ||
return Ember.Handlebars.template(templateSpec); | ||
var template = Ember.Handlebars.template(templateSpec); | ||
template.isMethod = false; //Make sure we don't wrap templates with ._super | ||
return template; | ||
}; | ||
@@ -276,0 +263,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
76
18417
2
257
+ Addedhandlebars@~1.0.0
+ Addedamdefine@1.0.1(transitive)
+ Addedasync@0.2.10(transitive)
+ Addedhandlebars@1.0.12(transitive)
+ Addedoptimist@0.3.7(transitive)
+ Addedsource-map@0.1.43(transitive)
+ Addeduglify-js@2.3.6(transitive)
+ Addedwordwrap@0.0.3(transitive)