GithubHelp home page GithubHelp logo

sealedenvelope / grunt-mustache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phun-ky/grunt-mustache

0.0 3.0 0.0 110 KB

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

License: GNU General Public License v2.0

JavaScript 100.00%

grunt-mustache's Introduction

grunt-mustache Build Status

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.

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.

grunt-mustache's People

Contributors

nilsel avatar

Watchers

Jon Ramsey avatar James Cloos avatar Tony Brady avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.