@kurdel/template-ejs 0.1.0-beta.1
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/LICENSE +21 -0
- package/README.md +61 -0
- package/lib/ejs-template-engine.d.ts +6 -0
- package/lib/ejs-template-engine.js +11 -0
- package/lib/ejs-template-engine.js.map +1 -0
- package/lib/ejs-template-module.d.ts +5 -0
- package/lib/ejs-template-module.js +19 -0
- package/lib/ejs-template-module.js.map +1 -0
- package/lib/ejs-template-options.d.ts +3 -0
- package/lib/ejs-template-options.js +2 -0
- package/lib/ejs-template-options.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Andrii Sorokin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @kurdel/template-ejs
|
|
2
|
+
|
|
3
|
+
Integration module for using **EJS templates** with the Kurdel framework.
|
|
4
|
+
Provides a unified `TemplateEngine` implementation for server-side rendering (SSR).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 📦 Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @kurdel/template-ejs
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
> Requires Node 20.19+, 22.12+, or 24+ and `@kurdel/core` / `@kurdel/runtime`.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🚀 Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { EjsTemplateModule } from '@kurdel/template-ejs';
|
|
22
|
+
import { createNodeApplication } from '@kurdel/facade';
|
|
23
|
+
|
|
24
|
+
const app = await createNodeApplication({
|
|
25
|
+
modules: [
|
|
26
|
+
EjsTemplateModule.forRoot({ baseDir: 'views' }),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
app.listen(3000);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Render a view from a controller:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { Controller, route, View } from '@kurdel/core/http';
|
|
36
|
+
|
|
37
|
+
export class HomeController extends Controller {
|
|
38
|
+
readonly routes = {
|
|
39
|
+
index: route({ method: 'GET', path: '/' })(this.index),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
async index() {
|
|
43
|
+
return View('home', { title: 'Welcome to Kurdel!' });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ⚙️ Options
|
|
51
|
+
|
|
52
|
+
| Option | Type | Default | Description |
|
|
53
|
+
| ----------- | -------- | --------- | ----------------------------------------------- |
|
|
54
|
+
| `baseDir` | `string` | `"views"` | Path to the directory containing EJS templates. |
|
|
55
|
+
| `extension` | `string` | `".ejs"` | Template file extension. |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 📄 License
|
|
60
|
+
|
|
61
|
+
MIT © Andrii Sorokin
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TemplateEngine } from '@kurdel/core/template';
|
|
2
|
+
export declare class EjsTemplateEngine implements TemplateEngine {
|
|
3
|
+
private readonly baseDir;
|
|
4
|
+
constructor(baseDir: string);
|
|
5
|
+
render(templatePath: string, data: Record<string, unknown>): Promise<string>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ejs from 'ejs';
|
|
2
|
+
export class EjsTemplateEngine {
|
|
3
|
+
constructor(baseDir) {
|
|
4
|
+
this.baseDir = baseDir;
|
|
5
|
+
}
|
|
6
|
+
async render(templatePath, data) {
|
|
7
|
+
const filePath = `${this.baseDir}/${templatePath}`;
|
|
8
|
+
return ejs.renderFile(filePath, data, { async: true });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ejs-template-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ejs-template-engine.js","sourceRoot":"","sources":["../src/ejs-template-engine.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAGtB,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,KAAK,CAAC,MAAM,CAAC,YAAoB,EAAE,IAA6B;QAC9D,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,YAAY,EAAE,CAAC;QACnD,OAAO,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAoB,CAAC;IAC5E,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TOKENS } from '@kurdel/core/tokens';
|
|
2
|
+
import { EjsTemplateEngine } from './ejs-template-engine.js';
|
|
3
|
+
export class EjsTemplateModule {
|
|
4
|
+
static forRoot(options) {
|
|
5
|
+
return {
|
|
6
|
+
exports: {
|
|
7
|
+
view: TOKENS.TemplateEngineToken,
|
|
8
|
+
},
|
|
9
|
+
providers: [
|
|
10
|
+
{
|
|
11
|
+
provide: TOKENS.TemplateEngineToken,
|
|
12
|
+
useFactory: () => new EjsTemplateEngine(options.baseDir),
|
|
13
|
+
singleton: true,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ejs-template-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ejs-template-module.js","sourceRoot":"","sources":["../src/ejs-template-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAC,OAAO,CAAC,OAAiC;QAC9C,OAAO;YACL,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM,CAAC,mBAAmB;aACjC;YAED,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,MAAM,CAAC,mBAAmB;oBACnC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC;oBACxD,SAAS,EAAE,IAAI;iBAChB;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ejs-template-options.js","sourceRoot":"","sources":["../src/ejs-template-options.ts"],"names":[],"mappings":""}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kurdel/template-ejs",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "EJS server-side rendering template engine for Kurdel",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./lib/index.js",
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"lib"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepack": "npm run build",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:ui": "vitest",
|
|
18
|
+
"test:watch": "vitest --watch",
|
|
19
|
+
"coverage": "vitest run --coverage",
|
|
20
|
+
"clean": "rimraf lib ../../.cache/tsconfig.template-ejs.build.tsbuildinfo",
|
|
21
|
+
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
22
|
+
"build:force": "npm run clean && tsc -p tsconfig.build.json --force && tsc-alias -p tsconfig.build.json"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"kurdel",
|
|
26
|
+
"ejs",
|
|
27
|
+
"ssr",
|
|
28
|
+
"template",
|
|
29
|
+
"framework"
|
|
30
|
+
],
|
|
31
|
+
"author": "Andrii Sorokin",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/ignorantic/kurdel.git",
|
|
39
|
+
"directory": "packages/template-ejs"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/ignorantic/kurdel/tree/main/packages/template-ejs#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/ignorantic/kurdel/issues"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"tag": "beta"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"ejs": "^3.1.10"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/ejs": "^3.1.5",
|
|
54
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
55
|
+
"rimraf": "^6.0.1",
|
|
56
|
+
"tsc-alias": "^1.8.16"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@kurdel/core": "0.1.0-beta.1"
|
|
60
|
+
}
|
|
61
|
+
}
|