@spinajs/templates 2.0.180 → 2.0.182
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.
- package/lib/cjs/cli/render.d.ts +12 -12
- package/lib/cjs/cli/render.js +85 -85
- package/lib/cjs/cli/render.js.map +1 -1
- package/lib/cjs/config/templates.d.ts +9 -9
- package/lib/cjs/config/templates.js +15 -15
- package/lib/cjs/index.d.ts +14 -14
- package/lib/cjs/index.js +69 -69
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +20 -20
- package/lib/cjs/interfaces.js +34 -34
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/mjs/cli/render.d.ts +12 -12
- package/lib/mjs/cli/render.js +59 -59
- package/lib/mjs/cli/render.js.map +1 -1
- package/lib/mjs/config/templates.d.ts +9 -9
- package/lib/mjs/config/templates.js +13 -13
- package/lib/mjs/index.d.ts +14 -14
- package/lib/mjs/index.js +52 -52
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +20 -20
- package/lib/mjs/interfaces.js +30 -30
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +7 -7
package/lib/cjs/cli/render.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CliCommand } from '@spinajs/cli';
|
|
2
|
-
import { Log } from '@spinajs/log-common';
|
|
3
|
-
interface RenderOptions {
|
|
4
|
-
file?: string;
|
|
5
|
-
model?: string;
|
|
6
|
-
lang?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class RenderTemplateCommand extends CliCommand {
|
|
9
|
-
protected Log: Log;
|
|
10
|
-
execute(template: string, options: RenderOptions): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
1
|
+
import { CliCommand } from '@spinajs/cli';
|
|
2
|
+
import { Log } from '@spinajs/log-common';
|
|
3
|
+
interface RenderOptions {
|
|
4
|
+
file?: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
lang?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class RenderTemplateCommand extends CliCommand {
|
|
9
|
+
protected Log: Log;
|
|
10
|
+
execute(template: string, options: RenderOptions): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
13
|
//# sourceMappingURL=render.d.ts.map
|
package/lib/cjs/cli/render.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.RenderTemplateCommand = void 0;
|
|
36
|
-
const index_js_1 = require("./../index.js");
|
|
37
|
-
const cli_1 = require("@spinajs/cli");
|
|
38
|
-
const di_1 = require("@spinajs/di");
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
const fs = __importStar(require("fs"));
|
|
41
|
-
const log_common_1 = require("@spinajs/log-common");
|
|
42
|
-
let RenderTemplateCommand = class RenderTemplateCommand extends cli_1.CliCommand {
|
|
43
|
-
async execute(template, options) {
|
|
44
|
-
this.Log.trace(`Rendering ${template}, options: ${JSON.stringify(options)}`);
|
|
45
|
-
try {
|
|
46
|
-
const templates = await di_1.DI.resolve(index_js_1.Templates);
|
|
47
|
-
let model = {};
|
|
48
|
-
if (options.model && fs.existsSync(options.model)) {
|
|
49
|
-
this.Log.trace(`Found model file at ${options.model}, trying to load model data ... `);
|
|
50
|
-
const mText = fs.readFileSync(options.model, { encoding: 'utf-8' });
|
|
51
|
-
model = JSON.parse(mText);
|
|
52
|
-
}
|
|
53
|
-
if (options && options.file) {
|
|
54
|
-
this.Log.trace(`Rendering template to file ${options.file} ...`);
|
|
55
|
-
const dir = path.dirname(options.file);
|
|
56
|
-
if (!fs.existsSync(dir)) {
|
|
57
|
-
this.Log.trace(`Directory ${dir} not exits, creating ...`);
|
|
58
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
-
}
|
|
60
|
-
await templates.renderToFile(template, model, options.file, options.lang);
|
|
61
|
-
this.Log.success(`Rendering template ${template} to file ${options.file} succeded !`);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const result = await templates.render(template, model, options.lang);
|
|
65
|
-
this.Log.success(`Rendering template ${template} succeded !`);
|
|
66
|
-
// print out to console in raw format
|
|
67
|
-
console.log(result);
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
this.Log.error(`Cannot render template ${template}, reason: ${err.message}, stack: ${err.stack}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
RenderTemplateCommand
|
|
79
|
-
|
|
80
|
-
(0, cli_1.
|
|
81
|
-
(0, cli_1.
|
|
82
|
-
(0, cli_1.Option)('-
|
|
83
|
-
(0, cli_1.Option)('-
|
|
84
|
-
],
|
|
85
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.RenderTemplateCommand = void 0;
|
|
36
|
+
const index_js_1 = require("./../index.js");
|
|
37
|
+
const cli_1 = require("@spinajs/cli");
|
|
38
|
+
const di_1 = require("@spinajs/di");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
42
|
+
let RenderTemplateCommand = class RenderTemplateCommand extends cli_1.CliCommand {
|
|
43
|
+
async execute(template, options) {
|
|
44
|
+
this.Log.trace(`Rendering ${template}, options: ${JSON.stringify(options)}`);
|
|
45
|
+
try {
|
|
46
|
+
const templates = await di_1.DI.resolve(index_js_1.Templates);
|
|
47
|
+
let model = {};
|
|
48
|
+
if (options.model && fs.existsSync(options.model)) {
|
|
49
|
+
this.Log.trace(`Found model file at ${options.model}, trying to load model data ... `);
|
|
50
|
+
const mText = fs.readFileSync(options.model, { encoding: 'utf-8' });
|
|
51
|
+
model = JSON.parse(mText);
|
|
52
|
+
}
|
|
53
|
+
if (options && options.file) {
|
|
54
|
+
this.Log.trace(`Rendering template to file ${options.file} ...`);
|
|
55
|
+
const dir = path.dirname(options.file);
|
|
56
|
+
if (!fs.existsSync(dir)) {
|
|
57
|
+
this.Log.trace(`Directory ${dir} not exits, creating ...`);
|
|
58
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
await templates.renderToFile(template, model, options.file, options.lang);
|
|
61
|
+
this.Log.success(`Rendering template ${template} to file ${options.file} succeded !`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const result = await templates.render(template, model, options.lang);
|
|
65
|
+
this.Log.success(`Rendering template ${template} succeded !`);
|
|
66
|
+
// print out to console in raw format
|
|
67
|
+
console.log(result);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.Log.error(`Cannot render template ${template}, reason: ${err.message}, stack: ${err.stack}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.RenderTemplateCommand = RenderTemplateCommand;
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, log_common_1.Logger)('templates'),
|
|
77
|
+
__metadata("design:type", log_common_1.Log)
|
|
78
|
+
], RenderTemplateCommand.prototype, "Log", void 0);
|
|
79
|
+
exports.RenderTemplateCommand = RenderTemplateCommand = __decorate([
|
|
80
|
+
(0, cli_1.Command)('template-render', 'Renders template, usefull for template testing'),
|
|
81
|
+
(0, cli_1.Argument)('template', 'template path, must be in one of directory provided in configs'),
|
|
82
|
+
(0, cli_1.Option)('-f, --file [file]', false, 'path for file, where parsing result will be saved'),
|
|
83
|
+
(0, cli_1.Option)('-m, --model [model]', false, 'path to optional model data, passed to template, in json format'),
|
|
84
|
+
(0, cli_1.Option)('-l, --lang [lang]', false, 'optional language. Language data must be in directories configured in intl module. If none provided, default language is used')
|
|
85
|
+
], RenderTemplateCommand);
|
|
86
86
|
//# sourceMappingURL=render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/cli/render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA0C;AAC1C,sCAAqE;AACrE,oCAAiC;AACjC,2CAA6B;AAC7B,uCAAyB;AACzB,oDAAkD;AAa3C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,gBAAU;IAI5C,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,OAAsB;QAC3D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,QAAQ,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE7E,IAAI;YACF,MAAM,SAAS,GAAG,MAAM,OAAE,CAAC,OAAO,CAAC,oBAAS,CAAC,CAAC;YAC9C,IAAI,KAAK,GAAG,EAAE,CAAC;YAEf,IAAI,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,OAAO,CAAC,KAAK,kCAAkC,CAAC,CAAC;gBAEvF,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;gBACpE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aAC3B;YAED,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE;gBAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC;gBAEj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E,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,QAAQ,YAAY,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC;gBACtF,OAAO;aACR;YAED,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YACrE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,QAAQ,aAAa,CAAC,CAAC;YAE9D,qCAAqC;YACrC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SACrB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,0BAA0B,QAAQ,aAAa,GAAG,CAAC,OAAO,YAAY,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;SACnG;IACH,CAAC;CACF,CAAA;AA5CY,sDAAqB;AAEtB;IADT,IAAA,mBAAM,EAAC,WAAW,CAAC;8BACL,gBAAG;kDAAC;gCAFR,qBAAqB;IALjC,IAAA,aAAO,EAAC,iBAAiB,EAAE,gDAAgD,CAAC;IAC5E,IAAA,cAAQ,EAAC,UAAU,EAAE,gEAAgE,CAAC;IACtF,IAAA,YAAM,EAAC,mBAAmB,EAAE,KAAK,EAAE,mDAAmD,CAAC;IACvF,IAAA,YAAM,EAAC,qBAAqB,EAAE,KAAK,EAAE,iEAAiE,CAAC;IACvG,IAAA,YAAM,EAAC,mBAAmB,EAAE,KAAK,EAAE,+HAA+H,CAAC;GACvJ,qBAAqB,CA4CjC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare const templates: {
|
|
2
|
-
system: {
|
|
3
|
-
dirs: {
|
|
4
|
-
templates: string[];
|
|
5
|
-
cli: string[];
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export default templates;
|
|
1
|
+
declare const templates: {
|
|
2
|
+
system: {
|
|
3
|
+
dirs: {
|
|
4
|
+
templates: string[];
|
|
5
|
+
cli: string[];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default templates;
|
|
10
10
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path_1 = require("path");
|
|
4
|
-
function dir(path) {
|
|
5
|
-
return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(process.cwd(), path)));
|
|
6
|
-
}
|
|
7
|
-
const templates = {
|
|
8
|
-
system: {
|
|
9
|
-
dirs: {
|
|
10
|
-
templates: [dir('./../templates')],
|
|
11
|
-
cli: [dir('./../cli')],
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
exports.default = templates;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
function dir(path) {
|
|
5
|
+
return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(process.cwd(), path)));
|
|
6
|
+
}
|
|
7
|
+
const templates = {
|
|
8
|
+
system: {
|
|
9
|
+
dirs: {
|
|
10
|
+
templates: [dir('./../templates')],
|
|
11
|
+
cli: [dir('./../cli')],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
exports.default = templates;
|
|
16
16
|
//# sourceMappingURL=templates.js.map
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { AsyncService } from '@spinajs/di';
|
|
2
|
-
import { Log } from '@spinajs/log';
|
|
3
|
-
import { TemplateRenderer } from './interfaces.js';
|
|
4
|
-
export * from './interfaces.js';
|
|
5
|
-
/**
|
|
6
|
-
* Inject INTL module for language support. We does nothing but to initialize module for use in templates.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Templates extends AsyncService {
|
|
9
|
-
protected Log: Log;
|
|
10
|
-
protected Renderers: Map<string, TemplateRenderer>;
|
|
11
|
-
getRendererFor(extname: string): TemplateRenderer;
|
|
12
|
-
render(template: string, model: unknown, language?: string): Promise<string>;
|
|
13
|
-
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
14
|
-
}
|
|
1
|
+
import { AsyncService } from '@spinajs/di';
|
|
2
|
+
import { Log } from '@spinajs/log';
|
|
3
|
+
import { TemplateRenderer } from './interfaces.js';
|
|
4
|
+
export * from './interfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Inject INTL module for language support. We does nothing but to initialize module for use in templates.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Templates extends AsyncService {
|
|
9
|
+
protected Log: Log;
|
|
10
|
+
protected Renderers: Map<string, TemplateRenderer>;
|
|
11
|
+
getRendererFor(extname: string): TemplateRenderer;
|
|
12
|
+
render(template: string, model: unknown, language?: string): Promise<string>;
|
|
13
|
+
renderToFile(template: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
14
|
+
}
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
-
};
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
23
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Templates = void 0;
|
|
27
|
-
const exceptions_1 = require("@spinajs/exceptions");
|
|
28
|
-
const di_1 = require("@spinajs/di");
|
|
29
|
-
const log_1 = require("@spinajs/log");
|
|
30
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
31
|
-
const path_1 = require("path");
|
|
32
|
-
const intl_1 = require("@spinajs/intl");
|
|
33
|
-
__exportStar(require("./interfaces.js"), exports);
|
|
34
|
-
/**
|
|
35
|
-
* Inject INTL module for language support. We does nothing but to initialize module for use in templates.
|
|
36
|
-
*/
|
|
37
|
-
let Templates = class Templates extends di_1.AsyncService {
|
|
38
|
-
getRendererFor(extname) {
|
|
39
|
-
return this.Renderers.get(extname);
|
|
40
|
-
}
|
|
41
|
-
async render(template, model, language) {
|
|
42
|
-
const extension = (0, path_1.extname)(template);
|
|
43
|
-
if (!this.Renderers.has(extension)) {
|
|
44
|
-
throw new exceptions_1.InvalidOperation(`No renderer for file ${template} with extension ${extension}`);
|
|
45
|
-
}
|
|
46
|
-
return await this.Renderers.get(extension).render(template, model, language);
|
|
47
|
-
}
|
|
48
|
-
async renderToFile(template, model, filePath, language) {
|
|
49
|
-
const extension = (0, path_1.extname)(template);
|
|
50
|
-
if (!this.Renderers.has(extension)) {
|
|
51
|
-
throw new exceptions_1.InvalidOperation(`No renderer for file ${template} with extension ${extension}`);
|
|
52
|
-
}
|
|
53
|
-
return await this.Renderers.get(extension).renderToFile(template, model, filePath, language);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Templates
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Templates = void 0;
|
|
27
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
28
|
+
const di_1 = require("@spinajs/di");
|
|
29
|
+
const log_1 = require("@spinajs/log");
|
|
30
|
+
const interfaces_js_1 = require("./interfaces.js");
|
|
31
|
+
const path_1 = require("path");
|
|
32
|
+
const intl_1 = require("@spinajs/intl");
|
|
33
|
+
__exportStar(require("./interfaces.js"), exports);
|
|
34
|
+
/**
|
|
35
|
+
* Inject INTL module for language support. We does nothing but to initialize module for use in templates.
|
|
36
|
+
*/
|
|
37
|
+
let Templates = class Templates extends di_1.AsyncService {
|
|
38
|
+
getRendererFor(extname) {
|
|
39
|
+
return this.Renderers.get(extname);
|
|
40
|
+
}
|
|
41
|
+
async render(template, model, language) {
|
|
42
|
+
const extension = (0, path_1.extname)(template);
|
|
43
|
+
if (!this.Renderers.has(extension)) {
|
|
44
|
+
throw new exceptions_1.InvalidOperation(`No renderer for file ${template} with extension ${extension}`);
|
|
45
|
+
}
|
|
46
|
+
return await this.Renderers.get(extension).render(template, model, language);
|
|
47
|
+
}
|
|
48
|
+
async renderToFile(template, model, filePath, language) {
|
|
49
|
+
const extension = (0, path_1.extname)(template);
|
|
50
|
+
if (!this.Renderers.has(extension)) {
|
|
51
|
+
throw new exceptions_1.InvalidOperation(`No renderer for file ${template} with extension ${extension}`);
|
|
52
|
+
}
|
|
53
|
+
return await this.Renderers.get(extension).renderToFile(template, model, filePath, language);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.Templates = Templates;
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, log_1.Logger)('templates'),
|
|
59
|
+
__metadata("design:type", log_1.Log)
|
|
60
|
+
], Templates.prototype, "Log", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, di_1.Autoinject)(interfaces_js_1.TemplateRenderer, {
|
|
63
|
+
mapFunc: (x) => x.ServiceName,
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:type", Map)
|
|
66
|
+
], Templates.prototype, "Renderers", void 0);
|
|
67
|
+
exports.Templates = Templates = __decorate([
|
|
68
|
+
(0, di_1.Inject)(intl_1.Intl)
|
|
69
|
+
], Templates);
|
|
70
70
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuD;AACvD,oCAA+D;AAC/D,sCAA2C;AAC3C,mDAAmD;AACnD,+BAA+B;AAC/B,wCAAqC;AACrC,kDAAgC;AAEhC;;GAEG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,iBAAY;IASlC,cAAc,CAAC,OAAe;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAG,KAAc,EAAE,QAAiB;QACtE,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,MAAM,IAAI,6BAAgB,CAAC,wBAAwB,QAAQ,mBAAmB,SAAS,EAAE,CAAC,CAAC;SAC5F;QAED,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,Q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AS,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/E,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,KAAc,EAAE,QAAgB,EAAE,QAAiB;QAC7F,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,MAAM,IAAI,6BAAgB,CAAC,wBAAwB,QAAQ,mBAAmB,SAAS,EAAE,CAAC,CAAC;SAC5F;QAED,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/F,CAAC;CACF,CAAA;AA9BY,8BAAS;AAEV;IADT,IAAA,YAAM,EAAC,WAAW,CAAC;8BACL,SAAG;sCAAC;AAKT;IAHT,IAAA,eAAU,EAAC,gCAAgB,EAAE;QAC5B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW;KAC9B,CAAC;8BACmB,GAAG;4CAA2B;oBAPxC,SAAS;IADrB,IAAA,WAAM,EAAC,WAAI,CAAC;GACA,SAAS,CA8BrB"}
|
package/lib/cjs/interfaces.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { IMappableService } from '@spinajs/di';
|
|
2
|
-
import { AsyncService } from '@spinajs/di';
|
|
3
|
-
import { Log } from '@spinajs/log';
|
|
4
|
-
export declare abstract class TemplateRenderer extends AsyncService implements IMappableService {
|
|
5
|
-
protected Log: Log;
|
|
6
|
-
protected TemplatePaths: string[];
|
|
7
|
-
protected TemplateFiles: Map<string, string[]>;
|
|
8
|
-
abstract get Type(): string;
|
|
9
|
-
abstract get Extension(): string;
|
|
10
|
-
get ServiceName(): string;
|
|
11
|
-
abstract render(templatePath: string, model: unknown, language?: string): Promise<string>;
|
|
12
|
-
abstract renderToFile(templatePath: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Function used for precompiling templates at load time. Not all template engines can support it, leave it empty if so.
|
|
15
|
-
*
|
|
16
|
-
* @param templateName - template name
|
|
17
|
-
* @param path - template full path
|
|
18
|
-
*/
|
|
19
|
-
protected abstract compile(templateName: string, path: string): Promise<void>;
|
|
20
|
-
}
|
|
1
|
+
import { IMappableService } from '@spinajs/di';
|
|
2
|
+
import { AsyncService } from '@spinajs/di';
|
|
3
|
+
import { Log } from '@spinajs/log';
|
|
4
|
+
export declare abstract class TemplateRenderer extends AsyncService implements IMappableService {
|
|
5
|
+
protected Log: Log;
|
|
6
|
+
protected TemplatePaths: string[];
|
|
7
|
+
protected TemplateFiles: Map<string, string[]>;
|
|
8
|
+
abstract get Type(): string;
|
|
9
|
+
abstract get Extension(): string;
|
|
10
|
+
get ServiceName(): string;
|
|
11
|
+
abstract render(templatePath: string, model: unknown, language?: string): Promise<string>;
|
|
12
|
+
abstract renderToFile(templatePath: string, model: unknown, filePath: string, language?: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Function used for precompiling templates at load time. Not all template engines can support it, leave it empty if so.
|
|
15
|
+
*
|
|
16
|
+
* @param templateName - template name
|
|
17
|
+
* @param path - template full path
|
|
18
|
+
*/
|
|
19
|
+
protected abstract compile(templateName: string, path: string): Promise<void>;
|
|
20
|
+
}
|
|
21
21
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/lib/cjs/interfaces.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TemplateRenderer = void 0;
|
|
13
|
-
const configuration_1 = require("@spinajs/configuration");
|
|
14
|
-
const di_1 = require("@spinajs/di");
|
|
15
|
-
const log_1 = require("@spinajs/log");
|
|
16
|
-
class TemplateRenderer extends di_1.AsyncService {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.TemplateFiles = new Map();
|
|
20
|
-
}
|
|
21
|
-
get ServiceName() {
|
|
22
|
-
// we map this service by extension
|
|
23
|
-
return this.Extension;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TemplateRenderer = void 0;
|
|
13
|
+
const configuration_1 = require("@spinajs/configuration");
|
|
14
|
+
const di_1 = require("@spinajs/di");
|
|
15
|
+
const log_1 = require("@spinajs/log");
|
|
16
|
+
class TemplateRenderer extends di_1.AsyncService {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.TemplateFiles = new Map();
|
|
20
|
+
}
|
|
21
|
+
get ServiceName() {
|
|
22
|
+
// we map this service by extension
|
|
23
|
+
return this.Extension;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.TemplateRenderer = TemplateRenderer;
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, log_1.Logger)('renderer'),
|
|
29
|
+
__metadata("design:type", log_1.Log)
|
|
30
|
+
], TemplateRenderer.prototype, "Log", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, configuration_1.Config)('system.dirs.templates', { defaultValue: [] }),
|
|
33
|
+
__metadata("design:type", Array)
|
|
34
|
+
], TemplateRenderer.prototype, "TemplatePaths", void 0);
|
|
35
35
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0DAAgD;AAChD,oCAA2C;AAC3C,sCAA2C;AAG3C,MAAsB,gBAAiB,SAAQ,iBAAY;IAA3D;;QAOY,kBAAa,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAqB/E,CAAC;IAfC,IAAW,WAAW;QACpB,mCAAmC;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CAYF;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0DAAgD;AAChD,oCAA2C;AAC3C,sCAA2C;AAG3C,MAAsB,gBAAiB,SAAQ,iBAAY;IAA3D;;QAOY,kBAAa,GAA0B,IAAI,GAAG,EAAoB,CAAC;IAqB/E,CAAC;IAfC,IAAW,WAAW;QACpB,mCAAmC;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CAYF;AA5BD,4CA4BC;AA1BW;IADT,IAAA,YAAM,EAAC,UAAU,CAAC;8BACJ,SAAG;6CAAC;AAGT;IADT,IAAA,sBAAM,EAAC,uBAAuB,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;;uDACpB"}
|
package/lib/mjs/cli/render.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CliCommand } from '@spinajs/cli';
|
|
2
|
-
import { Log } from '@spinajs/log-common';
|
|
3
|
-
interface RenderOptions {
|
|
4
|
-
file?: string;
|
|
5
|
-
model?: string;
|
|
6
|
-
lang?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class RenderTemplateCommand extends CliCommand {
|
|
9
|
-
protected Log: Log;
|
|
10
|
-
execute(template: string, options: RenderOptions): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
1
|
+
import { CliCommand } from '@spinajs/cli';
|
|
2
|
+
import { Log } from '@spinajs/log-common';
|
|
3
|
+
interface RenderOptions {
|
|
4
|
+
file?: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
lang?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class RenderTemplateCommand extends CliCommand {
|
|
9
|
+
protected Log: Log;
|
|
10
|
+
execute(template: string, options: RenderOptions): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
13
|
//# sourceMappingURL=render.d.ts.map
|