Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
/** | ||
* Configures templating engines for an app | ||
*/ | ||
class EngineResolver { | ||
constructor(app, conf) { | ||
this.app = app; | ||
this.conf = conf; | ||
} | ||
|
||
configure() { | ||
this.conf.engines.forEach((it) => { | ||
this.app.engine(it.ext, it.callback); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = EngineResolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
let chai = require("chai"); | ||
let expect = chai.expect; | ||
let EngineConfig = require("./engines"); | ||
|
||
describe("The 'engines' configuration section", () => { | ||
it("can configure templating engines for an app", () => { | ||
let engines = {}; | ||
let app = { | ||
engine (ext, callback) { | ||
engines[ext] = callback; | ||
} | ||
}; | ||
let conf = { | ||
engines: [ | ||
{ | ||
ext: "jade", | ||
callback: () => "derp" | ||
} | ||
] | ||
}; | ||
|
||
new EngineConfig(app, conf).configure(); | ||
expect(engines.jade).to.be.a.function; | ||
expect(engines.jade()).to.equal("derp"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters