Skip to content

Commit

Permalink
4.0.0
Browse files Browse the repository at this point in the history
* Update to Handlebars 3.0.0, closes #48
* Update dependencies
* Fix tests
* Rename all handlebars3 examples to handlebars2
  • Loading branch information
lazd committed Mar 3, 2015
1 parent ae594df commit 6349fff
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Compile and register partials with Handlebars 3
# Compile and register partials with Handlebars 2.x

This example will show you how to compile partials and templates down to a single file.

The stream merging technique is from gulp's [Using multiple sources in one task recipe](https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md).

## Dependencies

* [`handlebars@3.0.0`](https://www.npmjs.org/package/handlebars) - The latest version of handlebars
* [`handlebars@2.0.0`](https://www.npmjs.org/package/handlebars) - An older version of handlebars
* [`gulp-declare`](https://www.npmjs.org/package/gulp-declare) - Declare properties and sub-properties
* [`gulp-concat`](https://www.npmjs.org/package/gulp-concat) - Combine output into a single file
* [`gulp-wrap`](https://www.npmjs.org/package/gulp-wrap) - Add `require()` and `Handlebars.template()` statements
Expand All @@ -18,7 +18,7 @@ Type the following commands from the root of this repository:

```
npm install # install the plugin's dependencies
cd examples/handlebars3-partials
cd examples/handlebars2-partials
npm install # install the example's dependencies
gulp
open build/index.html
Expand All @@ -36,7 +36,7 @@ This is the partial!

```shell
# Note the specific version of Handlebars is specified here
npm install --save-dev gulp-handlebars gulp-wrap gulp-declare gulp-concat merge-stream handlebars@3.0.0
npm install --save-dev gulp-handlebars gulp-wrap gulp-declare gulp-concat merge-stream handlebars@2.0.0
```

#### 2. Add the `require()` statements and `template` task to your gulpfile
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "gulp-handlebars-partials",
"description": "An example that shows how to compile partials gulp-handlebars",
"description": "An example that shows how to compile partials with gulp-handlebars and Handlebars 2.x",
"version": "0.0.0",
"main": "gulpfile.js",
"devDependencies": {
"gulp-concat": "^2.4.1",
"gulp-wrap": "^0.5.0",
"handlebars": "^3.0.0",
"handlebars": "^2.0.0",
"merge-stream": "^0.1.6"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Compile templates against Handlebars 3.x
# Compile templates against Handlebars 2.x

This example will show you how to compile templates using a specific version of Handlebars.

**The runtime you include on the client side MUST match the version you compile templates with.** You cannot use the the 2.x runtime with 3.x templates. This example copies the runtime from `node_modules/handlebars/dist/handlebars.runtime.js` and uses that on the client side. Follow a similar pattern in your application to keep the runtime up to date with the compiler.
**The runtime you include on the client side MUST match the version you compile templates with.** You cannot use the the 3.x runtime with 2.x templates. This example copies the runtime from `node_modules/handlebars/dist/handlebars.runtime.js` and uses that on the client side. Follow a similar pattern in your application to keep the runtime up to date with the compiler.

## Dependencies

* [`handlebars@3.0.0`](https://www.npmjs.org/package/handlebars) - The latest version of handlebars
* [`handlebars@2.0.0`](https://www.npmjs.org/package/handlebars) - An older version of handlebars
* [`gulp-declare`](https://www.npmjs.org/package/gulp-declare) - Declare properties and sub-properties
* [`gulp-concat`](https://www.npmjs.org/package/gulp-concat) - Combine output into a single file
* [`gulp-wrap`](https://www.npmjs.org/package/gulp-wrap) - Add `require()` and `Handlebars.template()` statements
Expand All @@ -17,8 +17,8 @@ Type the following commands from the root of this repository:

```
npm install # install the plugin's dependencies
cd examples/handlebars3
npm install # install Handlebars 3.x locally
cd examples/handlebars2
npm install # install Handlebars 2.x locally
gulp
open build/index.html
```
Expand All @@ -34,7 +34,7 @@ This is the app!

```shell
# Note the specific version of Handlebars is specified here
npm install --save-dev gulp-handlebars gulp-wrap gulp-declare gulp-concat handlebars@3.0.0
npm install --save-dev gulp-handlebars gulp-wrap gulp-declare gulp-concat handlebars@2.0.0
```

#### 2. Add the `require()` statements and `template` task to your gulpfile
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/handlebars2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "gulp-handlebars-handlebars2",
"description": "An example of using Handlebars 2.x with gulp-handlebars",
"version": "0.0.0",
"main": "gulpfile.js",
"devDependencies": {
"handlebars": "^2.0.0"
}
}
File renamed without changes.
9 changes: 0 additions & 9 deletions examples/handlebars3/package.json

This file was deleted.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "gulp-handlebars",
"version": "3.0.1",
"version": "4.0.0",
"description": "Handlebars plugin for gulp",
"main": "index.js",
"dependencies": {
"through2": "^0.6.1",
"handlebars": "^2.0.0",
"gulp-util": "^3.0.0"
"through2": "^0.6.3",
"handlebars": "^3.0.0",
"gulp-util": "^3.0.4"
},
"devDependencies": {
"ember-handlebars": "^1.2.0",
"gulp": "^3.8.7",
"gulp-concat": "^2.3.4",
"gulp": "^3.8.11",
"gulp-concat": "^2.5.2",
"gulp-declare": "^0.3.0",
"gulp-define-module": "^0.1.1",
"gulp-wrap": "^0.3.0",
"mocha": "^1.21.4",
"gulp-wrap": "^0.11.0",
"mocha": "^2.1.0",
"nsdeclare": "^0.1.0",
"should": "^4.0.4"
"should": "^5.0.1"
},
"scripts": {
"test": "./node_modules/.bin/mocha"
Expand Down
4 changes: 2 additions & 2 deletions test/expected/Basic.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "Basic template";
},"useData":true}
return "Basic template";
},"useData":true}
4 changes: 2 additions & 2 deletions test/expected/Basic_namespace.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MyApp.templates["Basic"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "Basic template";
},"useData":true});
return "Basic template";
},"useData":true});
4 changes: 2 additions & 2 deletions test/expected/Basic_node.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var Handlebars = require("handlebars");module.exports = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "Basic template";
},"useData":true});
return "Basic template";
},"useData":true});
4 changes: 2 additions & 2 deletions test/expected/Basic_preprocessed.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "Preprocessed template";
},"useData":true}
return "Preprocessed template";
},"useData":true}
2 changes: 1 addition & 1 deletion test/expected/Error.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Parse error on line 1:
...syntax error: {{foo }}}
-----------------------^
Expecting 'CLOSE', got 'CLOSE_UNESCAPED'
Expecting 'CLOSE', 'OPEN_SEXPR', 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'DATA', got 'CLOSE_UNESCAPED'
2 changes: 1 addition & 1 deletion test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('gulp-handlebars', function() {
it('should process AST', function(done) {
var stream = handlebarsPlugin({
processAST: function(ast) {
ast.statements[0].string = 'Preprocessed template';
ast.body[0].value = 'Preprocessed template';
}
});
var basicTemplate = getFixture('Basic.hbs');
Expand Down

0 comments on commit 6349fff

Please sign in to comment.