@tsed/engines 6.114.0 → 7.0.0-beta.11
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/components/RactiveEngine.js +1 -0
- package/lib/cjs/components/RactiveEngine.js.map +1 -1
- package/lib/cjs/registries/EnginesContainer.js.map +1 -1
- package/lib/esm/components/RactiveEngine.js +1 -0
- package/lib/esm/components/RactiveEngine.js.map +1 -1
- package/lib/esm/registries/EnginesContainer.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
|
@@ -8,6 +8,7 @@ let RactiveEngine = class RactiveEngine extends Engine_1.Engine {
|
|
|
8
8
|
$compile(template, options) {
|
|
9
9
|
const Engine = this.engine;
|
|
10
10
|
const compile = this.engine.parse(template);
|
|
11
|
+
Engine.DEBUG = false;
|
|
11
12
|
return (options) => {
|
|
12
13
|
options.template = compile;
|
|
13
14
|
return new Engine(this.clean(options)).toHTML();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RactiveEngine.js","sourceRoot":"","sources":["../../../src/components/RactiveEngine.ts"],"names":[],"mappings":";;;;AAAA,yDAAoD;AACpD,qCAA+C;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,eAAM;IAC7B,QAAQ,CAAC,QAAgB,EAAE,OAAsB;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"RactiveEngine.js","sourceRoot":"","sources":["../../../src/components/RactiveEngine.ts"],"names":[],"mappings":";;;;AAAA,yDAAoD;AACpD,qCAA+C;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,eAAM;IAC7B,QAAQ,CAAC,QAAgB,EAAE,OAAsB;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,OAAO,CAAC,OAAsB,EAAE,EAAE;YAChC,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;YAC3B,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,OAAY;QAC1B,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;YACvD,mCAAmC;YACnC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YAE1C,wDAAwD;YACxD,IAAI,CAAC,CAAC;YACN,IAAI,MAAM,CAAC;YACX,IAAI,UAAU,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAE/D,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;gBACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBAC/B,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC/B;SACF;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA7BY,aAAa;IADzB,IAAA,uBAAU,EAAC,SAAS,CAAC;GACT,aAAa,CA6BzB;AA7BY,sCAAa","sourcesContent":["import {ViewEngine} from \"../decorators/viewEngine\";\nimport {Engine, EngineOptions} from \"./Engine\";\n\n@ViewEngine(\"ractive\")\nexport class RactiveEngine extends Engine {\n protected $compile(template: string, options: EngineOptions) {\n const Engine = this.engine;\n const compile = this.engine.parse(template);\n Engine.DEBUG = false;\n return (options: EngineOptions) => {\n options.template = compile;\n return new Engine(this.clean(options)).toHTML();\n };\n }\n\n protected clean(options: any) {\n if (options.data === null || options.data === undefined) {\n // Shallow clone the options object\n options.data = Object.assign({}, options);\n\n // Remove consolidate-specific properties from the clone\n let i;\n let length;\n let properties = [\"template\", \"filename\", \"cache\", \"partials\"];\n\n for (i = 0, length = properties.length; i < length; i++) {\n const property = properties[i];\n delete options.data[property];\n }\n }\n\n return options;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnginesContainer.js","sourceRoot":"","sources":["../../../src/registries/EnginesContainer.ts"],"names":[],"mappings":";;;;;AASA,MAAa,gBAAgB;IAA7B;QACE,sCAA0D,IAAI,GAAG,EAAE,EAAC;IAwBtE,CAAC;IAtBC,GAAG,CAAC,GAA2B;QAC7B,OAAO,+BAAA,IAAI,mCAAW,CAAC,GAAG,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"EnginesContainer.js","sourceRoot":"","sources":["../../../src/registries/EnginesContainer.ts"],"names":[],"mappings":";;;;;AASA,MAAa,gBAAgB;IAA7B;QACE,sCAA0D,IAAI,GAAG,EAAE,EAAC;IAwBtE,CAAC;IAtBC,GAAG,CAAC,GAA2B;QAC7B,OAAO,+BAAA,IAAI,mCAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAAC,GAA2B;QAC7B,MAAM,QAAQ,GAAG,+BAAA,IAAI,mCAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE1C,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAClC,QAAQ,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;SAC5E;QAED,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,GAAkB,EAAE,QAAwB;QAC9C,+BAAA,IAAI,mCAAW,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnC,+BAAA,IAAI,mCAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,mBAAmB;QACjB,OAAO,CAAC,GAAG,+BAAA,IAAI,mCAAW,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAa,CAAC;IAC1F,CAAC;CACF;AAzBD,4CAyBC;;AAEY,QAAA,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["import {Engine, ViewEngineOptions} from \"../components/Engine\";\n\nexport interface EngineProvider {\n name: string;\n useClass: typeof Engine;\n instance?: Engine;\n options: ViewEngineOptions;\n}\n\nexport class EnginesContainer {\n #providers: Map<string | typeof Engine, EngineProvider> = new Map();\n\n has(key: string | typeof Engine) {\n return this.#providers.has(key);\n }\n\n get(key: string | typeof Engine) {\n const provider = this.#providers.get(key);\n\n if (provider && !provider.instance) {\n provider.instance = new provider.useClass(provider.name, provider.options);\n }\n\n return provider?.instance;\n }\n\n set(key: typeof Engine, provider: EngineProvider) {\n this.#providers.set(key, provider);\n this.#providers.set(provider.name, provider);\n }\n\n getSupportedEngines(): string[] {\n return [...this.#providers.keys()].filter((key) => typeof key === \"string\") as string[];\n }\n}\n\nexport const engines = new EnginesContainer();\n"]}
|
|
@@ -5,6 +5,7 @@ let RactiveEngine = class RactiveEngine extends Engine {
|
|
|
5
5
|
$compile(template, options) {
|
|
6
6
|
const Engine = this.engine;
|
|
7
7
|
const compile = this.engine.parse(template);
|
|
8
|
+
Engine.DEBUG = false;
|
|
8
9
|
return (options) => {
|
|
9
10
|
options.template = compile;
|
|
10
11
|
return new Engine(this.clean(options)).toHTML();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RactiveEngine.js","sourceRoot":"","sources":["../../../src/components/RactiveEngine.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,MAAM,EAAgB,MAAM,UAAU,CAAC;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,MAAM;IAC7B,QAAQ,CAAC,QAAgB,EAAE,OAAsB;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"RactiveEngine.js","sourceRoot":"","sources":["../../../src/components/RactiveEngine.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,MAAM,EAAgB,MAAM,UAAU,CAAC;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,MAAM;IAC7B,QAAQ,CAAC,QAAgB,EAAE,OAAsB;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,OAAO,CAAC,OAAsB,EAAE,EAAE;YAChC,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;YAC3B,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,OAAY;QAC1B,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;YACvD,mCAAmC;YACnC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YAE1C,wDAAwD;YACxD,IAAI,CAAC,CAAC;YACN,IAAI,MAAM,CAAC;YACX,IAAI,UAAU,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAE/D,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;gBACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBAC/B,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC/B;SACF;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA7BY,aAAa;IADzB,UAAU,CAAC,SAAS,CAAC;GACT,aAAa,CA6BzB;SA7BY,aAAa","sourcesContent":["import {ViewEngine} from \"../decorators/viewEngine\";\nimport {Engine, EngineOptions} from \"./Engine\";\n\n@ViewEngine(\"ractive\")\nexport class RactiveEngine extends Engine {\n protected $compile(template: string, options: EngineOptions) {\n const Engine = this.engine;\n const compile = this.engine.parse(template);\n Engine.DEBUG = false;\n return (options: EngineOptions) => {\n options.template = compile;\n return new Engine(this.clean(options)).toHTML();\n };\n }\n\n protected clean(options: any) {\n if (options.data === null || options.data === undefined) {\n // Shallow clone the options object\n options.data = Object.assign({}, options);\n\n // Remove consolidate-specific properties from the clone\n let i;\n let length;\n let properties = [\"template\", \"filename\", \"cache\", \"partials\"];\n\n for (i = 0, length = properties.length; i < length; i++) {\n const property = properties[i];\n delete options.data[property];\n }\n }\n\n return options;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnginesContainer.js","sourceRoot":"","sources":["../../../src/registries/EnginesContainer.ts"],"names":[],"mappings":";;AASA,MAAM,OAAO,gBAAgB;IAA7B;QACE,sCAA0D,IAAI,GAAG,EAAE,EAAC;IAwBtE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engine, ViewEngineOptions} from \"../components/Engine\";\n\nexport interface EngineProvider {\n name: string;\n useClass: typeof Engine;\n instance?: Engine;\n options: ViewEngineOptions;\n}\n\nexport class EnginesContainer {\n #providers: Map<string | typeof Engine, EngineProvider> = new Map();\n\n has(key: string | typeof Engine) {\n return this.#providers.has(key);\n }\n\n get(key: string | typeof Engine) {\n const provider = this.#providers.get(key);\n\n if (provider && !provider.instance) {\n provider.instance = new provider.useClass(provider.name, provider.options);\n }\n\n return provider?.instance;\n }\n\n set(key: typeof Engine, provider: EngineProvider) {\n this.#providers.set(key, provider);\n this.#providers.set(provider.name, provider);\n }\n\n getSupportedEngines(): string[] {\n return [...this.#providers.keys()].filter((key) => typeof key === \"string\") as string[];\n }\n}\n\nexport const engines = new EnginesContainer();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/engines",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.11",
|
|
4
4
|
"description": "Template engines library. Provide an API to adding custom engines from decorators.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"bugs": {
|
|
95
95
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
96
96
|
},
|
|
97
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
97
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/engines",
|
|
98
98
|
"author": "Romain Lenzotti",
|
|
99
99
|
"license": "MIT"
|
|
100
100
|
}
|
package/readme.md
CHANGED
|
@@ -212,7 +212,7 @@ requires.get("nunjucks").addFilter("foo", () => {
|
|
|
212
212
|
});
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
-
## Implement
|
|
215
|
+
## Implement your own engine
|
|
216
216
|
|
|
217
217
|
`@tsed/engines` let you register your own engine by using the `@ViewEngine` decorator. Here an is example of
|
|
218
218
|
pug engine implementation:
|