Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down