swaggie 0.7.0-alpha.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,20 +2,18 @@
|
|
|
2
2
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
3
3
|
var _eta = require('eta'); var Eta = _interopRequireWildcard(_eta);
|
|
4
4
|
|
|
5
|
-
let templatesDir = null;
|
|
6
|
-
|
|
7
5
|
function loadAllTemplateFiles(templateName) {
|
|
8
6
|
if (!templateName) {
|
|
9
7
|
throw new Error(`No template name was provided`);
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
templatesDir = _fs2.default.existsSync(templateName)
|
|
10
|
+
const templatesDir = _fs2.default.existsSync(templateName)
|
|
13
11
|
? templateName
|
|
14
12
|
: _path2.default.join(__dirname, '..', '..', 'templates', templateName);
|
|
15
13
|
|
|
16
14
|
if (!_fs2.default.existsSync(templatesDir)) {
|
|
17
15
|
throw new Error(
|
|
18
|
-
`Could not found directory with the template (we tried ${templatesDir}). Template name is correct
|
|
16
|
+
`Could not found directory with the template (we tried ${templatesDir}). Template name is correct?`
|
|
19
17
|
);
|
|
20
18
|
}
|
|
21
19
|
const templates = _fs2.default.readdirSync(templatesDir);
|
|
@@ -28,6 +26,6 @@ let templatesDir = null;
|
|
|
28
26
|
} exports.loadAllTemplateFiles = loadAllTemplateFiles;
|
|
29
27
|
|
|
30
28
|
function renderFile(templateFile, data = {}) {
|
|
31
|
-
const
|
|
32
|
-
return Eta.
|
|
29
|
+
const template = Eta.templates.get(templateFile);
|
|
30
|
+
return Eta.render(template, data);
|
|
33
31
|
} exports.renderFile = renderFile;
|