-
Notifications
You must be signed in to change notification settings - Fork 6
options.templateParams
Eugene Lazutkin edited this page Mar 18, 2014
·
4 revisions
Type: Object
Default value: {}
This is a way to pass additional parameters to a template engine.
While grunt allows to use arbitrary JavaScript, which can be used
to generate a template with predetermined static inclusions
(see options.template),
this option is more useful for passing parameters to a template
specified as an external file
(see options.templateFile).
An object will be passed to a template as params variable.
A custom template, which will be referred by options.templateFile (we use the modified default here as an example):
.<%= className %> {
background: url(<%= url %>?cacheBust=<%= params.cacheBust %>) -<%= x %>px -<%= y %>px no-repeat;
width: <%= w %>px;
height: <%= h %>px;
}With this config:
grunt.initConfig({
tight_sprite: {
icons: {
options: {
templateFile: "../css/customTemplate.css",
templateParams: {cacheBust: new Date().getTime()},
hide: "images/icons/"
},
src: ["images/icons/**/*.png"],
dest: "images/icons.png"
}
}
})It will produce a following fragment:
...
.sprite_x16_address_16 {
background: url(sprite1.png?cacheBust=1293723384552) -1568px -144px no-repeat;
width: 16px;
height: 16px;
}
...