-
Notifications
You must be signed in to change notification settings - Fork 6
options.templateParams
Eugene Lazutkin edited this page Jul 11, 2014
·
4 revisions
Type: Object
Default value: {}
This is a way to pass additional parameters to a template engine. This option was designed 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;
}
/* ... */