Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Grunt plugin for testing mustache templates

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tasks
test
.gitignore
.jshintrc
Gruntfile.js
LICENSE-MIT
README.md
package.json

README.md

grunt-mustache-render

Render mustache templates

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-mustache-render --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-mustache-render');

The "mustache_render" task

Overview

In your project's Gruntfile, add a section named mustache_render to the data object passed into grunt.initConfig().

grunt.initConfig({
  mustache_render: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

File lists must be in the following format:

files: [
  {data: "path/to/data/file.json",
   template: "path/to/template.mustache",
   dest: "file/to/output.html"}
]

Each object in the file array represents one rendered template. Data files can be in either JSON or YAML format.

Options

COMING SOON!

Usage Examples

For this Grunt config:

grunt.initConfig({
  mustache_render: {
    files: [{
      data: "data/hello_world.json",
      template: "templates/hello_world.mustache",
      dest: "public/hello_world.html"
    }],
  },
})

And this json:

{
  "greeting" : "Hello",
  "target" : "World"
}

This template:

<html>
<head>
  <meta charset="UTF-8">
  <title>A greeting</title>
</head>
<body>
  <h1>{{greeting}}, {{target}}!</h1>
</body>
</html>

Will produce this output:

<html>
<head>
  <meta charset="UTF-8">
  <title>A greeting</title>
</head>
<body>
  <h1>Hello, World!</h1>
</body>
</html>

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.2.0

  • YAML data file support

0.1.0

  • Initial Release
Something went wrong with that request. Please try again.