Skip to content

Commit

Permalink
Fixed output file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pvorb committed Aug 21, 2011
1 parent 6259dfb commit 627aa26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/conf/bake.json
Expand Up @@ -4,10 +4,10 @@
"templates": "tpl"
},
"fileExtensions": {
"txt": "html",
"mkd": "html",
"md": "html",
"markdown": "html"
"markdown": "html",
"txt": "html"
},
"defaultTemplate": "default",
"properties": {
Expand Down
17 changes: 12 additions & 5 deletions lib/bake.js
Expand Up @@ -23,9 +23,9 @@ var bake = function(confFile, hooks) {
tplDir = conf.directories.templates || "tpl";

// Set values for `fileExt`
var fileExt = conf.fileExtensions || { txt: "txt" };
var fileExt = conf.fileExtensions || { txt: "html" };
var fileExtPattern
= new RegExp("\\.(" + Object.keys(fileExt).join("|") + ")$", "gi");
= new RegExp("\.(" + Object.keys(fileExt).join("|") + ")$", "i");

// Status log
console.log("Beginning to bake " + bakeDir + ".\n");
Expand All @@ -35,8 +35,14 @@ var bake = function(confFile, hooks) {
// Throw errors
if (err) throw err;

// Match the master-file's name against markdown file extensions
if (master.match(fileExtPattern)) {
// Matching variable
var match;

// Match the master-file's name against enabled file extensions
if (match = master.match(fileExtPattern)) {

// Get the file extension of the master file
var masterExt = match[1];

// Increase file counter
++todo;
Expand Down Expand Up @@ -80,7 +86,8 @@ var bake = function(confFile, hooks) {
file.__content);

// Result's filename
var resultFilename = master.replace(fileExtPattern, ".html");
var resultFilename = master.replace(fileExtPattern,
"." + fileExt[masterExt]);

// Export `file` and `global` to locals object for use in the
// template.
Expand Down

0 comments on commit 627aa26

Please sign in to comment.