Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Latest commit

 

History

History
94 lines (60 loc) · 3.46 KB

README.md

File metadata and controls

94 lines (60 loc) · 3.46 KB

grunt-mustache

Retire Status Build Status Dependency Status NPM version

A grunt plugin to concatinate mustache template files into a valid JavaScript syntax file.

This plugin does NOT bake JSON data with mustache templates. This plugin is created to handle the template baking with mustache/handlebars within a web projects internal JavaScript methods.

No more development

I will no longer develop this plugin any further and I strongly suggest users of this plugin to either fork it and continue the development on their hand, or find another plugin.

Getting Started

Install this grunt plugin next to your project's Gruntfile.js with:

npm install grunt-mustache

Then add this line to your project's Gruntfile.js:

grunt.loadNpmTasks('grunt-mustache');

Documentation

Add something like this in your gruntfile:

mustache: {
  files : {
    src: 'src/main/webapp/js/mustache/',
    dest: 'src/main/webapp/js/src/templates.js',
    options: {
      prefix: 'my.templates = ',
      postfix: ';',
      verbose: true
    }
  }
}

Note: If postfix/prefix options are set or not, you can either create a JS object;

my.templates = {"templatename": 'template-data' [...], "done": "true"};

or a JSON-ish-string:

({"templatename": 'template-data' [...], "done", "true"})

The parenthesis are there to produce a valid JavaScript file. In the future we might change this to write a JSON file if no pre/post-fix is set.

Options

prefix

  • Type: String
  • Defaults: (

String to prepend the generated string. Defaults to ( to give a valid JavaScript string.

postfix

  • Type: String
  • Defaults: )

String to append the generated string. Defaults to ) to give a valid JavaScript string.

verbose

  • Type: Boolean
  • Defaults: false

Toggle for verbose output.

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

(Until v1.0.0, this will only be updated when major or breaking changes are made)

10/01/2013: Added support for grunt v 0.4.0rc5

01/01/2013: Pull request merged for some linting fixes and updates for readme

30/12/2012: Minor tweaks: removed requirement for postfix/prefix option, trailing whitespace cleanup, updated docs (nilsel)

21/12/2012: Upgraded task to fit grunt v 0.4*, renamed old gruntfile and added postfix/prefix support for template generation. removed old config.varname functionality

19/12/2012: Edited script for newer grunt-version (didn't get it to work quite right, replaced helper with callback, added some options for variable name + minor stuff)

License

Copyright (c) 2012 Alexander Vassbotn Røyne-Helgesen
Licensed under the GPL license.