gruntplugin for create modular macroses, that prepare source files
npm install grunt-pragma





Gruntplugin for create modular macroses, that prepare source files
~0.4.xIf 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:
``shell`
npm install grunt-pragma --save
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-pragma');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
pragma: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
`$3
#### 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:
`js
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'
]
}]
}
},
});
`$3
####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
``