grunt-pragma v1.2.2
grunt-pragma
Gruntplugin for create modular macroses, that prepare source files
Getting Started
This plugin requires Grunt ~0.4.x
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-pragma --saveOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-pragma');The "pragma" task
Overview
In your project's Gruntfile, add a section named pragma to the data object passed into grunt.initConfig().
grunt.initConfig({
  pragma: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});Options
options.processors
Type: String
Default value: process.cwd()
You can use any function as processor of pragma tag specified in options hash.
Any processor function has 3 arguments: 1) params array 2) inner string (or null, if you didn't use block pragma tag) 3) source string (with pragma tag)
example:
grunt.initConfig({
  pragma: {
    convert: {
      options: {
        debugMode: true,
        ifDebug: function (params, inner, source) { // pragma processor
          return this['debugMode'] ? inner : '';
        }
        // in files will be find tags /*@ifDebug:*/ /*:ifDebug@*/ abd /*@ifDebug:@*/
      },
      files: [{
        expand: true,
        cwd: 'examples',
        dest: '.tmp',
        ext: '.php',
        src: [
          '**/*.json'
        ]
      }]
    }
  },
});Tags
####block tag pattern: /\/*@(a-zA-Z0-9_+):((?!=*)^\/)*\/(\s\S?)\/*:\1@*\//g
examples:
before text
/*@somePragmaTag: "someparam1", "someParam2"*/
inner text
/*:somePragmaTag@*/
after textwithout params
before text
/*@somePragmaTag:*/
inner text
/*:somePragmaTag@*/
after textall params must be valid JSON
####inline tag pattern: /\/*@(a-zA-Z0-9_+):((?!=@)^**)@*\//gm
examples:
before text /*@somePragmaTag: "someparam1", "someParam2" @*/ after textwithout params
before text /*@somePragmaTag:@*/ after text