diff --git a/README.md b/README.md index 09463eb..b9371cc 100644 --- a/README.md +++ b/README.md @@ -126,10 +126,12 @@ module.exports["App"]["Header"] = /* File contents from App.Header.js */; module.exports["App"]["Footer"] = /* File contents from App.Footer.js */; ``` -### declare.processNameByPath(filePath) +### declare.processNameByPath(filePath, separatorFormat) Pass this method as `options.processName` so the path within the namespace matches the path in the filesystem combined with dot notation from the filename: +The `separatorFormat` is optional that it changes the dot notation in other notation type. + ```js gulp.src(['templates/**/*.html']) .pipe(domly()) // Compile HTML to document fragment builder functions diff --git a/index.js b/index.js index 29bf0c5..a7b3624 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,11 @@ var declare = require('nsdeclare'); // Default name processing function should give the filename without extension var defaultProcessName = function(name) { return path.basename(name, path.extname(name)); }; -var processNameByPath = function(filePath) { +var processNameByPath = function(filePath, separatorFormat) { + + // By default the separator format for join is a dot but it can be something else + separatorFormat = typeof separatorFormat !== 'undefined' ? separatorFormat : '.'; + // Make the directory relative filePath = path.relative(process.cwd(), filePath); @@ -20,7 +24,7 @@ var processNameByPath = function(filePath) { parts.push(templateName); // Turn the path into dot notation - return parts.join('.'); + return parts.join(separatorFormat); }; module.exports = function(options) {