Supporting custom template extension
Fix missing escape
This commit is contained in:
+11
-2
@@ -42,6 +42,12 @@ var optimist = require('optimist')
|
|||||||
'type': 'string',
|
'type': 'string',
|
||||||
'description': 'Template root. Base value that will be stripped from template names.',
|
'description': 'Template root. Base value that will be stripped from template names.',
|
||||||
'alias': 'root'
|
'alias': 'root'
|
||||||
|
},
|
||||||
|
'e': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Template extension.',
|
||||||
|
'alias': 'extension',
|
||||||
|
'default': 'handlebars'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -87,6 +93,9 @@ if (argv.known) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build file extension pattern
|
||||||
|
var extension = new RegExp('\\.' + argv.extension + '$');
|
||||||
|
|
||||||
var output = [];
|
var output = [];
|
||||||
if (!argv.simple) {
|
if (!argv.simple) {
|
||||||
if (argv.amd) {
|
if (argv.amd) {
|
||||||
@@ -103,7 +112,7 @@ function processTemplate(template, root) {
|
|||||||
fs.readdirSync(template).map(function(file) {
|
fs.readdirSync(template).map(function(file) {
|
||||||
var path = template + '/' + file;
|
var path = template + '/' + file;
|
||||||
|
|
||||||
if (/\.handlebars$/.test(path) || fs.statSync(path).isDirectory()) {
|
if (extension.test(path) || fs.statSync(path).isDirectory()) {
|
||||||
processTemplate(path, root || template);
|
processTemplate(path, root || template);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -121,7 +130,7 @@ function processTemplate(template, root) {
|
|||||||
} else if (template.indexOf(root) === 0) {
|
} else if (template.indexOf(root) === 0) {
|
||||||
template = template.substring(root.length+1);
|
template = template.substring(root.length+1);
|
||||||
}
|
}
|
||||||
template = template.replace(/\.handlebars$/, '');
|
template = template.replace(extension, '');
|
||||||
|
|
||||||
if (argv.simple) {
|
if (argv.simple) {
|
||||||
output.push(handlebars.precompile(data, options) + '\n');
|
output.push(handlebars.precompile(data, options) + '\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user