grunt-xslate
v0.1.1
Published
Compile Text::Xslate template files from Grunt.
Downloads
3
Readme
grunt-xslate
Compile Text::Xslate template files from Grunt.
Getting Started
This plugin requires Grunt ~0.4.0
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-xslate --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-xslate');
This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that you upgrade, but in case you can't please use v0.3.2.
and install xslate
command or your command.
cpanm Text::Xslate
Xslate task
Run this task with the grunt xslate
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Options
cartonExec
Enebale to carton exec
command.
If you are using a carton
, you should enable.
runner
Rather than xslate
command, you can run the perl command that you have defined.
write your perl, and grant excute authority.
e.g.
#!/usr/bin/env perl
use Text::Xslate;
my ($template_path, ) = @ARGV;
my $engine = Text::Xslate->new(%your_options);
print $engine->render(template_path, \%your_arguments);
chmod 755 bin/your-engine.pl
data
Define template variables.
This will be passed to define
option of xslate
command.
syntax
You can specified template syntax.(e.g. Kolon)
formatter
You can rocess the data to be specified define
{
xslate: {
example: {
options: {
formatter: function (value, name) {
return JSON.stringify(value) // --define="foo={"fuga":1000, "hoge":2000}"
},
data: {
foo: {
fuga: 1000,
hoge: 2000,
}
}
}
}
}
}
Usage Example
xslate: {
basic: {
options: {
cartonExec: true,
data: {
content: 'this is the message!',
}
},
files:
'dist/output.html': 'src/input.tx'
},
original: {
options: {
cartonExec: true,
syntax: null,
runner: 'bin/my-xslate',
},
files: [
expand: true,
flatten: true,
ext: '.html',
src: '**/*.tx',
dest: 'dist/'
]
}
}