Permalink
Browse files

Cleaned some things up.

  • Loading branch information...
1 parent 90b44cd commit 3fdedbb6506cbaa535abfcf80201e711467ff407 @chrisabrams chrisabrams committed Jan 29, 2013
Showing with 260 additions and 459 deletions.
  1. +0 −5 AUTHORS
  2. +0 −39 CHANGELOG
  3. +85 −95 Gruntfile.js
  4. +16 −97 README.md
  5. +0 −15 docs/handlebars-examples.md
  6. +0 −68 docs/handlebars-options.md
  7. +0 −3 docs/handlebars-overview.md
  8. +71 −44 package.json
  9. +88 −93 tasks/handlebars.js
View
@@ -1,5 +0,0 @@
-Tim Branyen (http://tbranyen.com)
-Tyler Kellen (http://goingslowly.com/)
-Chris Talkington (http://christalkington.com/)
-David Mosher (http://blog.davemo.com/)
-Larry Davis (http://lazd.net/)
View
@@ -1,39 +0,0 @@
-v0.5.0rc7:
- date: 2013-01-23
- changes:
- - Updating grunt/gruntplugin dependencies to rc7.
- - Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
- - Default wrapped option to true.
-v0.4.0rc5:
- date: 2013-01-09
- changes:
- - Updating to work with grunt v0.4.0rc5.
- - Switching to this.files api.
-v0.3.3:
- date: 2012-11-21
- changes:
- - Reset for each target
-v0.3.2:
- date: 2012-10-12
- changes:
- - Rename grunt-contrib-lib dep to grunt-lib-contrib.
-v0.3.1:
- date: 2012-10-03
- changes:
- - Bugfix default processPartialName.
-v0.3.0:
- date: 2012-09-23
- changes:
- - Options no longer accepted from global config key.
-v0.2.3:
- date: 2012-09-16
- changes:
- - Support for nested namespaces.
-v0.2.2:
- date: 2012-09-12
- changes:
- - Escape single quotes in filenames.
-v0.2.0:
- date: 2012-09-10
- changes:
- - Refactored from grunt-contrib into individual repo.
View
@@ -1,95 +1,85 @@
-/*
- * grunt-contrib-handlebars
- * http://gruntjs.com/
- *
- * Copyright (c) 2012 Tim Branyen, contributors
- * Licensed under the MIT license.
- */
-
-'use strict';
-
-module.exports = function(grunt) {
-
- // Project configuration.
- grunt.initConfig({
- jshint: {
- all: [
- 'Gruntfile.js',
- 'tasks/*.js',
- '<%= nodeunit.tests %>'
- ],
- options: {
- jshintrc: '.jshintrc'
- }
- },
-
- // Before generating any new files, remove any previously-created files.
- clean: {
- tests: ['tmp']
- },
-
- // Configuration to be run (and then tested).
- handlebars: {
- compile: {
- options: {
- namespace: 'JST'
- },
- files: {
- 'tmp/handlebars.js': ['test/fixtures/_partial.hbs', 'test/fixtures/one.hbs']
- }
- },
- wrapcompile: {
- options: {
- namespace: 'JST',
- wrapped: true
- },
- files: {
- 'tmp/handlebarswrap.js': ['test/fixtures/_partial.hbs', 'test/fixtures/one.hbs']
- }
- },
- uglyfile: {
- files: {
- 'tmp/uglyfile.js': ['test/fixtures/*bad-filename*']
- }
- },
- ns_nested: {
- options: {
- namespace: 'MyApp.JST.Main'
- },
- files: {
- 'tmp/ns_nested.js': ['test/fixtures/basic.hbs']
- }
- },
- ns_nested_this: {
- options: {
- namespace: 'this.MyApp.JST.Main'
- },
- files: {
- 'tmp/ns_nested_this.js': ['test/fixtures/basic.hbs']
- }
- }
- },
-
- // Unit tests.
- nodeunit: {
- tests: ['test/*_test.js']
- }
- });
-
- // Actually load this plugin's task(s).
- grunt.loadTasks('tasks');
-
- // These plugins provide necessary tasks.
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-nodeunit');
- grunt.loadNpmTasks('grunt-contrib-internal');
-
- // Whenever the "test" task is run, first clean the "tmp" dir, then run this
- // plugin's task(s), then test the result.
- grunt.registerTask('test', ['clean', 'handlebars', 'nodeunit']);
-
- // By default, lint and run all tests.
- grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
-
-};
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ jshint: {
+ all: [
+ 'Gruntfile.js',
+ 'tasks/*.js',
+ '<%= nodeunit.tests %>'
+ ],
+ options: {
+ jshintrc: '.jshintrc'
+ }
+ },
+
+ // Before generating any new files, remove any previously-created files.
+ clean: {
+ tests: ['tmp']
+ },
+
+ // Configuration to be run (and then tested).
+ handlebars: {
+ compile: {
+ options: {
+ namespace: 'JST'
+ },
+ files: {
+ 'tmp/handlebars.js': ['test/fixtures/_partial.hbs', 'test/fixtures/one.hbs']
+ }
+ },
+ wrapcompile: {
+ options: {
+ namespace: 'JST',
+ wrapped: true
+ },
+ files: {
+ 'tmp/handlebarswrap.js': ['test/fixtures/_partial.hbs', 'test/fixtures/one.hbs']
+ }
+ },
+ uglyfile: {
+ files: {
+ 'tmp/uglyfile.js': ['test/fixtures/*bad-filename*']
+ }
+ },
+ ns_nested: {
+ options: {
+ namespace: 'MyApp.JST.Main'
+ },
+ files: {
+ 'tmp/ns_nested.js': ['test/fixtures/basic.hbs']
+ }
+ },
+ ns_nested_this: {
+ options: {
+ namespace: 'this.MyApp.JST.Main'
+ },
+ files: {
+ 'tmp/ns_nested_this.js': ['test/fixtures/basic.hbs']
+ }
+ }
+ },
+
+ // Unit tests.
+ nodeunit: {
+ tests: ['test/*_test.js']
+ }
+ });
+
+ // Actually load this plugin's task(s).
+ grunt.loadTasks('tasks');
+
+ // These plugins provide necessary tasks.
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-nodeunit');
+ grunt.loadNpmTasks('grunt-contrib-internal');
+
+ // Whenever the "test" task is run, first clean the "tmp" dir, then run this
+ // plugin's task(s), then test the result.
+ grunt.registerTask('test', ['clean', 'handlebars', 'nodeunit']);
+
+ // By default, lint and run all tests.
+ grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
+
+};
View
113 README.md
@@ -1,128 +1,47 @@
-# grunt-contrib-handlebars [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-handlebars.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-handlebars)
-
-> Precompile Handlebars templates to JST file.
+# grunt-commonjs-handlebars [![Build Status](https://secure.travis-ci.org/avos/grunt-commonjs-handlebars.png?branch=master)](http://travis-ci.org/avos/grunt-contrib-handlebars)
+> Precompile Handlebars templates into commonjs modules.
## Getting Started
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
```shell
-npm install grunt-contrib-handlebars --save-dev
+npm install grunt-commonjs-handlebars --save-dev
```
-
[grunt]: http://gruntjs.com/
[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
-
## Handlebars task
_Run this task with the `grunt handlebars` command._
_This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation._
[multi task]: https://github.com/gruntjs/grunt/wiki/Configuring-tasks
-
-_Version `0.4.x` of this plugin is compatible with Grunt `0.4.x`. Version `0.3.x` of this plugin is compatible with Grunt `0.3.x`._
-
-### Options
-
-#### separator
-Type: `String`
-Default: linefeed + linefeed
-
-Concatenated files will be joined on this string.
-
-#### namespace
-Type: `String`
-Default: 'JST'
-
-The namespace in which the precompiled templates will be assigned. *Use dot notation (e.g. App.Templates) for nested namespaces.*
-
-Example:
-```js
-options: {
- namespace: 'MyApp.Templates'
-}
-```
-
-#### wrapped
-Type: `Boolean`
-Default: `false`
-
-Determine if preprocessed template functions will be wrapped in Handlebars.template function.
-
-#### processName
-Type: `function`
-
-This option accepts a function which takes one argument (the template filepath) and returns a string which will be used as the key for the precompiled template object. The example below stores all templates on the default JST namespace in capital letters.
-
-```js
-options: {
- processName: function(filename) {
- return filename.toUpperCase();
- }
-}
-```
-
-#### processPartialName
-Type: ```function```
-
-This option accepts a function which takes one argument (the partial filepath) and returns a string which will be used as the key for the precompiled partial object when it is registered in Handlebars.partials. The example below stores all partials using only the actual filename instead of the full path.
-
-```js
-options: {
- processPartialName: function(filePath) { // input: templates/_header.hbs
- var pieces = filePath.split("/");
- return pieces[pieces.length - 1]; // output: _header.hbs
- }
-}
-````
-
-Note: If processPartialName is not provided as an option the default assumes that partials will be stored by stripping trailing underscore characters and filename extensions. For example, the path *templates/_header.hbs* will become *header* and can be referenced in other templates as *{{> header}}*.
-
-#### partialRegex
-Type: `Regexp`
-Default: /^_/
-
-This option accepts a regex that defines the prefix character that is used to identify Handlebars partial files.
-
-``` javascript
-// assumes partial files would be prefixed with "par_" ie: "par_header.hbs"
-options: {
- partialRegex: /^par_/
-}
-```
-
### Usage Examples
```js
handlebars: {
- compile: {
- options: {
- namespace: "JST"
- },
+ dist: {
files: {
"path/to/result.js": "path/to/source.hbs",
"path/to/another.js": ["path/to/sources/*.hbs", "path/to/more/*.hbs"]
}
+ },
+
+ //This is an example to convert each .hbs into its own .js file.
+ dev: {
+ files: grunt.file.expandMapping(['app/views/templates/**/*.hbs'], 'tmp/views/templates/', {
+ rename: (destBase, destPath) ->
+ return destBase + destPath.split('app/views/templates/')[1].replace /\.hbs$/, '.js'
+ })
}
}
```
-
## Release History
- * 2013-01-22   v0.5.0rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. Default wrapped option to true.
- * 2013-01-08   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to this.files api.
- * 2012-11-20   v0.3.3   Reset for each target
- * 2012-10-11   v0.3.2   Rename grunt-contrib-lib dep to grunt-lib-contrib.
- * 2012-10-02   v0.3.1   Bugfix default processPartialName.
- * 2012-09-22   v0.3.0   Options no longer accepted from global config key.
- * 2012-09-15   v0.2.3   Support for nested namespaces.
- * 2012-09-11   v0.2.2   Escape single quotes in filenames.
- * 2012-09-09   v0.2.0   Refactored from grunt-contrib into individual repo.
-
----
-
-Task submitted by [Tim Branyen](http://tbranyen.com)
+ * 2013-01-22   v0.1.0rc7   Initial release.
-*This file was generated on Wed Jan 23 2013 11:13:19.*
+## License
+Copyright (c) 2012 Team Delicious, AVOS Systems Inc., Tim Branyen, contributors
+Licensed under the MIT license.
@@ -1,15 +0,0 @@
-# Usage Examples
-
-```js
-handlebars: {
- compile: {
- options: {
- namespace: "JST"
- },
- files: {
- "path/to/result.js": "path/to/source.hbs",
- "path/to/another.js": ["path/to/sources/*.hbs", "path/to/more/*.hbs"]
- }
- }
-}
-```
Oops, something went wrong.

0 comments on commit 3fdedbb

Please sign in to comment.