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 --save
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "pragma" task
Overview
In your project's Gruntfile, add a section named pragma
to the data object passed into grunt.initConfig()
.
grunt;
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:
- params array
- inner string (or null, if you didn't use block pragma tag)
- source string (with pragma tag)
example:
grunt;
Tags
block tag
pattern: //*@([a-zA-Z0-9_]+):((?!=*)[^/])*/([\s\S]?)/*:\1@*//g
examples:
before text
/*@somePragmaTag: "someparam1", "someParam2"*/
inner text
/*:somePragmaTag@*/
after text
without params
before text
/*@somePragmaTag:*/
inner text
/*:somePragmaTag@*/
after text
all params must be valid JSON
inline tag
pattern: //*@([a-zA-Z0-9_]+):((?!=@)[^*]*)@*//gm
examples:
before text /*@somePragmaTag: "someparam1", "someParam2" @*/ after text
without params
before text /*@somePragmaTag:@*/ after text