Skip to content

Commit

Permalink
Accept files in format
Browse files Browse the repository at this point in the history
  • Loading branch information
5thWall committed Nov 28, 2013
1 parent d71b499 commit 33aa58e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Gruntfile.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ module.exports = function(grunt) {
dest: 'tmp/hello_yaml.html'} dest: 'tmp/hello_yaml.html'}
] ]
}, },
yml_data: {
files: [
{data: 'test/fixtures/objects/hello_world.yml',
template: 'test/fixtures/templates/hello_world.html.mustache',
dest: 'tmp/hello_yml.html'}
]
},
arbitrary_data: { arbitrary_data: {
files: [ files: [
{data: { greeting: "Hello", target: "world" }, {data: { greeting: "Hello", target: "world" },
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
# grunt-mustache-render v1.2.2 # grunt-mustache-render v1.2.3


[![Build Status](https://travis-ci.org/5thWall/mustache-render.png?branch=master)](https://travis-ci.org/5thWall/mustache-render) [![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) [![NPM version](https://badge.fury.io/js/grunt-mustache-render.png)](http://badge.fury.io/js/grunt-mustache-render)
Expand Down Expand Up @@ -152,6 +152,10 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.


## Release History ## Release History


__1.2.3__

* Accept `YAML` files with either `.yaml` or `.yml` extensions.

__1.2.2__ __1.2.2__


* Major code refactor * Major code refactor
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
{ {
"name": "grunt-mustache-render", "name": "grunt-mustache-render",
"description": "Render mustache templates", "description": "Render mustache templates",
"version": "1.2.2", "version": "1.2.3",
"homepage": "http://blog.the5thwall.net/mustache-render", "homepage": "http://blog.the5thwall.net/mustache-render",
"author": { "author": {
"name": "Andy Arminio", "name": "Andy Arminio",
Expand Down
2 changes: 1 addition & 1 deletion tasks/mustache_render.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = function gruntTask(grunt) {
GMR.prototype._getDataFromFile = function getDataFromFile(dataPath) { GMR.prototype._getDataFromFile = function getDataFromFile(dataPath) {
if (/\.json/i.test(dataPath)) { if (/\.json/i.test(dataPath)) {
return grunt.file.readJSON(dataPath); return grunt.file.readJSON(dataPath);
} else if (/\.yaml/i.test(dataPath)) { } else if (/\.ya?ml/i.test(dataPath)) {
return grunt.file.readYAML(dataPath); return grunt.file.readYAML(dataPath);
} }


Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/objects/hello_world.yml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
---
greeting: "Hello"
target: "world"
10 changes: 10 additions & 0 deletions test/mustache_render_test.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ exports.mustache_render = {
test.done(); test.done();
}, },


yml_data: function(test) {
test.expect(1);

var actual = grunt.file.read('tmp/hello_yml.html');
var expected = grunt.file.read('test/expected/hello_world.html');
test.equal(actual, expected, 'should render when given yml data.');

test.done();
},

arbitrary_data: function(test) { arbitrary_data: function(test) {
test.expect(1); test.expect(1);


Expand Down

0 comments on commit 33aa58e

Please sign in to comment.