Permalink
Browse files

Added template properties: relSrc, basename

  • Loading branch information...
1 parent e2a9700 commit 7a30810abdd9b6b0fe3dea2d5496cb7d11c5774f @eprev committed Feb 22, 2013
Showing with 9 additions and 3 deletions.
  1. +3 −1 README.md
  2. +6 −2 tasks/fest.js
View
@@ -70,7 +70,9 @@ Default value: `undefined`
This function is called when template will be compiled. It takes an argument as an object with the following properties:
* `src` — path to the template
+* `relSrc` — relative path to the template
* `name` — template’s name (relative to the source directory and w/o the extension)
+* `basename` — template’s basename
* `contents` — compiled template
### Usage Examples
@@ -145,7 +147,7 @@ grunt.initConfig({
template: function (data) {
// Make AMD module
return grunt.template.process(
- 'define(<%= JSON.stringify(name) %>, function () { return <%= contents %> ; });',
+ 'define(<%= JSON.stringify(relSrc) %>, function () { return <%= contents %> ; });',
{data: data}
);
},
View
@@ -24,14 +24,15 @@ module.exports = function (grunt) {
ext: '.js'
}),
extname = path.extname,
+ basename = path.basename,
join = path.join,
relative = path.relative;
var compile = require(requireResolve(options.require)).compile;
this.files.forEach(function (f) {
f.src.forEach(function (src) {
- var dest, relSrc, contents;
+ var dest, relSrc, name, contents;
if (f.orig.expand) {
dest = f.dest;
relSrc = f.orig.cwd ? relative(f.orig.cwd, src) : src;
@@ -53,9 +54,12 @@ module.exports = function (grunt) {
}
if (contents) {
if (options.template) {
+ name = se ? relSrc.slice(0, -se.length) : relSrc;
contents = options.template({
- name: se ? relSrc.slice(0, -se.length) : relSrc,
src: src,
+ relSrc: relSrc,
+ name: name,
+ basename: basename(name),
contents: contents
});
}

0 comments on commit 7a30810

Please sign in to comment.