Giter Site home page Giter Site logo

fossabot / grunt-script-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samuelneff/grunt-script-template

0.0 1.0 0.0 62 KB

Grunt task to generate files using script-template

License: MIT License

TypeScript 96.48% JavaScript 3.52%

grunt-script-template's Introduction

grunt-script-template

Grunt task to generate files using script-template.

Overview

FOSSA Status

To use grunt-script-template you'll need three things: a template, data, and a destination. grunt-script-template will then run the data against the template and store the result in the specified destination. Both the template and destination are specified as relative paths to the files. Data may be specified as JSON data within the Gruntfile.js or can be specified as a function which will be evaluated with the result run against the template.

Specification

Inside your grunt.initConfig call you'll want to specify each template you want to run and a corresponding template (src), destination (dest), and data (data).

For example, the following is the configuration for the tests included with grunt-script-template:

grunt.initConfig({

    pkg: 'package.json',

    'script-template': {
        'static-array-test': {
            src: 'test/static-array-template.ts',
            dest: 'temp/static-array.ts',
            data: ['One', 'Two', 'Three']
        },
        'static-object-test': {
            src: 'test/static-object-template.ts',
            dest: 'temp/static-object.ts',
            data: {title: 'Static Object Title', values: ['a', 'b', 'c']}
        },
        'dynamic-one-test': {
            src: 'test/dynamic-one-template.ts',
            dest: 'temp/dynamic-one.ts',
            data: getData                        
                    // getData is a previously defined function,
                    // notice no parenthesis, passing the function, 
                    // not the results
        }
    },

    clean: {
        tests: ['temp']
    },

    'jasmine_node': {
        'tests': ['test/']
    }
});

grunt.loadNpmTasks('grunt-script-template');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-jasmine-node');

grunt.registerTask('default', ['clean', 'script-template', 'jasmine_node']);

script-template

script-template is a simple templating engine designed to generate scripts (JavaScript, TypeScript, CoffeeScript). The main advantage of this engine is that the source templates are themselves valid JavaScript/TypeScript/CoffeeScript.

For more information on templates and data, see https://github.com/samuelneff/script-template.

License

Copyright (c) 2014 Samuel Neff Licensed under the (MIT license)[https://github.com/samuelneff/grunt-script-template/blob/master/LICENSE-MIT].

FOSSA Status

grunt-script-template's People

Contributors

fossabot avatar samuelneff avatar

Watchers

 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.