How to use the grunt.template function in grunt

To help you get started, we’ve selected a few grunt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apigeecs / apigee-deploy-grunt-plugin / tests / forecastweather-grunt-plugin-api.js View on Github external
/*globals describe:true, it:true, expect:true, before:true, beforeEach:true, after:true, afterEach:true*/
/*jslint node: true */

var grunt = require('grunt');
var testDataFilename = grunt.template.process("<%= apigee_profiles[grunt.option('env')].apiproxy + '-' + grunt.option('env') + '-data' %>");
var async = require('async')
var chai = require('chai')
var assert = require('chai').assert
var expect = require('chai').expect
var request = require('request'), chaiHttp = require('chai-http');
var weatherData = require('./' + testDataFilename);

chai.use(chaiHttp);

describe('ForecastWeather Public API Test',function() {
  "use strict";
  before(function () {
    // get OAuth 2.0 token
    // console.log('initialize');
  });
  beforeEach(function () {
github getdave / grunt-deployments / lib / dbReplace.js View on Github external
});

        shell.exec(scp_cmd);


        // 2) Build an SSH command
        ssh_cmd = grunt.template.process(tpls.ssh, {
            data: {
                user: config.ssh_user,
                host: config.ssh_host,
                port: (typeof config.ssh_port === "undefined") ? '22' : config.ssh_port
            }
        });

        // 3) Execute search-replace-db script on remote server
        cmd = grunt.template.process( tpls.search_replace, {
            data: {
                scriptPath: "~/search-replace-db/",
                host: config.host,
                user: config.user,
                pass: config.pass,
                database: config.database,
                search: search,
                replace: replace,
                flags: "" // dry run
            }
        });

        cmd = ssh_cmd + " '" + cmd + "'";

        // Return for reference and test suite purposes */
        shell.exec(cmd);
github sindresorhus / grunt-recess / tasks / lib / RecessTask.js View on Github external
RecessTask.prototype.run = function () {
	var cb = this.task.async();
	var files = this.task.files;
	var options = this.task.options(RecessTask.DEFAULT_OPTIONS);

	var banner = grunt.template.process(options.banner);
	var footer = grunt.template.process(options.footer);
	var reporter = false;

	if (!files.length) {
		grunt.log.writeln('No destinations specified.');
		cb();
		return;
	}

	// hook the reporting in...
	if (options.report && options.report.reporter) {
		reporter = {};
		reporter.proto = require(__dirname + '/reporters/' + options.report.reporter + '.js');
		reporter.mapping = options.report.mapping ? grunt.file.readJSON(options.report.mapping) : {};
		reporter.inst = new reporter.proto(reporter.mapping);
		options.compress = false;
		options.compile = true;
github wri / gfw-mapbuilder / 1.1.7 / vendor / pickadate / version-bump.js View on Github external
function updateLibraryFiles(version) {

  var versionRegex = /^(\s*\/\*![^\/]+?v)(\d+\.\d+\.\d+)(([^\n]+?)(\d+\/\d+\/\d+))?/
  var today = grunt.template.today('yyyy/mm/dd')
  var files = glob('lib/*.js')

  files.forEach(updateLibraryFile)

  function updateLibraryFile(filePath) {
    var content = grunt.file.read(filePath)
    if (versionRegex.test(content)) {
      content = content.split(versionRegex)
      content = content[1] + version + (content[4] || '') + (content[5] ? today : '') + (content[6] || '')
    }
    grunt.file.write(filePath, content)
  }

}
github alexpopdev / underscorejs-examples / browser-server-database / browser-underscore-templates / bower_components / jasmine / grunt / tasks / version.js View on Github external
copyToGem: function() {
    var versionRb = grunt.template.process(
      grunt.file.read("grunt/templates/version.rb.jst"),
      { data: { jasmineVersion: nodeToRuby(global.jasmineVersion) }});

    grunt.file.write(gemLib("version.rb"), versionRb);
  }
};
github facebook / react / grunt / tasks / react-dom.js View on Github external
function build(name, filename) {
  var srcFile = `vendor/${filename}.js`;
  var destFile = `build/${filename}.js`;
  var destFileMin = `build/${filename}.min.js`;
  var templateData = {
    package: name,
    version: grunt.config.data.pkg.version,
  };
  var header = grunt.template.process(
    LICENSE_TEMPLATE,
    {data: templateData}
  );
  var src = grunt.file.read(srcFile);
  var srcMin = UglifyJS.minify(src, {fromString: true}).code;
  grunt.file.write(destFile, header + src);
  grunt.file.write(destFileMin, header + srcMin);
}
github javaConductor / gserv / src / main / resources / docs / app / lib / jasmine / grunt / config / concat.js View on Github external
function license() {
    var currentYear = "" + new Date(Date.now()).getFullYear();

    return grunt.template.process(
        grunt.file.read("grunt/templates/licenseBanner.js.jst"),
        {data: {currentYear: currentYear}});
}
github dciccale / grunt-processhtml / lib / utils.js View on Github external
utils.template = function (tmpl, options) {
  return grunt.template.process(tmpl, options);
};
github jonschlinkert / grunt-readme / tasks / lib / mixins.js View on Github external
exports.copyright = function (startYear) {
  var name = config.author.name || config.author;
  var today = grunt.template.today('yyyy');
  var date = startYear ? startYear + '-' + today : today;
  return 'Copyright (c) ' + date + ' ' + name + ', contributors.';
};
github MeoMix / StreamusChromeExtension / node_modules / grunt-text-replace / lib / grunt-text-replace.js View on Github external
processGruntTemplate: function (string) {
    var isProcessTemplateTrue = true;
    if (grunt.task.current.data &&
        grunt.task.current.data.options &&
        typeof grunt.task.current.data.options.processTemplates !== 'undefined' &&
        grunt.task.current.data.options.processTemplates === false) {
      isProcessTemplateTrue = false;
    }
    return isProcessTemplateTrue ? grunt.template.process(string) : string;
  }