Skip to content

Commit

Permalink
Minor clarifications for using JS module format
Browse files Browse the repository at this point in the history
Changes some documentation and text strings surrounding the JS module
input format:

- differentiates use of dynamic module files in the introduction against
  using the static data formats
- clarify that URLs can only be used for JSON and YAML input, not for JS
  modules
- updates exception in _getDataFromFile() to mention JS modules as an
  acceptable input format
- adjust the unit test message for the JS module format
  • Loading branch information
corpulentcoffee committed Dec 18, 2014
1 parent 6cd5fc5 commit b12871c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/5thWall/mustache-render.png?branch=master)](https://travis-ci.org/5thWall/mustache-render)
[![NPM version](https://badge.fury.io/js/grunt-mustache-render.png)](http://badge.fury.io/js/grunt-mustache-render)

This is a grunt plugin to render [mustache](http://mustache.github.io/) templates. It takes data in `JSON`, `YAML`, `JS` or `POJO` (Plain Ol' JavaScript Object) format. It allows you to specify a folder for partials, instead of needing to list them individually.
This is a grunt plugin to render [mustache](http://mustache.github.io/) templates. It takes data in static `JSON`, static `YAML`, `JS` module, or a `POJO` (Plain Ol' JavaScript Object) format. It allows you to specify a folder for partials, instead of needing to list them individually.

## Getting Started
This plugin requires Grunt `~0.4.1`
Expand Down Expand Up @@ -37,7 +37,7 @@ grunt.initConfig({
},
files : [
{
data: // Path or URL to JS, JSON or YAML file, or POJO
data: // Path to JS module, path or URL to JSON or YAML, or POJO
template: // Path or URL to template file
dest: // Path to output destination here
}
Expand Down
3 changes: 2 additions & 1 deletion tasks/mustache_render.js
Expand Up @@ -160,7 +160,8 @@ module.exports = function gruntTask(grunt) {
return require(path.resolve('.', dataPath));
}

throw new Error("Data file must be JSON or YAML. Given: " + dataPath);
throw new Error("Data file must be JSON file, YAML file, or JS module. " +
"Given: " + dataPath);
};

// Internal: Ensure template is in proper format and retrieve its body.
Expand Down
2 changes: 1 addition & 1 deletion test/mustache_render_test.js
Expand Up @@ -106,7 +106,7 @@ exports.mustache_render = {
var actual = grunt.file.read('tmp/hello_js.html');
var expected = grunt.file.read('test/expected/hello_world.html');

test.equal(actual, expected, 'should render when given arbitrary data.');
test.equal(actual, expected, 'should render when given a JavaScript module.');

test.done();
},
Expand Down

0 comments on commit b12871c

Please sign in to comment.