@prairielearn/html-ejs 2.0.10 → 2.0.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/CHANGELOG.md +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAuB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,aAAqB,EAAE,QAAgB,EAAE,OAAY,EAAE;IAC/E,IAAI,YAAY,GAAG,aAAa,CAAC;IAEjC,8EAA8E;IAC9E,oDAAoD;IACpD,IAAI,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport ejs from 'ejs';\n\nimport { type HtmlSafeString, unsafeHtml } from '@prairielearn/html';\n/**\n * This is a shim to allow for the use of EJS templates inside of HTML tagged\n * template literals.\n *\n * The resulting string is assumed to be appropriately escaped and will be used\n * verbatim in the resulting HTML.\n *\n * @param filePathOrUrl The path or file URL of the file from which relative includes should be resolved.\n * @param template The raw EJS template string.\n * @param data Any data to be made available to the template.\n * @returns The rendered EJS.\n */\nexport function renderEjs(filePathOrUrl: string, template: string, data: any = {}): HtmlSafeString {\n let resolvedPath = filePathOrUrl;\n\n // This allows for us to pass `import.meta.url` to this function in ES Modules\n // environments where `__filename` is not available.\n if (filePathOrUrl.startsWith('file://')) {\n resolvedPath = fileURLToPath(filePathOrUrl);\n }\n\n return unsafeHtml(ejs.render(template, data, { views: [path.dirname(resolvedPath)] }));\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prairielearn/html-ejs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "https://github.com/PrairieLearn/PrairieLearn.git",
|
|
9
8
|
"directory": "packages/html-ejs"
|
|
10
9
|
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"dev": "tsc --watch --preserveWatchOutput",
|
|
14
14
|
"test": "c8 mocha src/**/*.test.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@prairielearn/html": "^4.0.
|
|
17
|
+
"@prairielearn/html": "^4.0.11",
|
|
18
18
|
"ejs": "^3.1.10"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@prairielearn/tsconfig": "^0.0.0",
|
|
22
22
|
"@types/ejs": "^3.1.5",
|
|
23
|
-
"@types/node": "^20.17.
|
|
23
|
+
"@types/node": "^20.17.28",
|
|
24
24
|
"c8": "^10.1.3",
|
|
25
25
|
"chai": "^5.2.0",
|
|
26
26
|
"mocha": "^11.1.0",
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
|
|
4
4
|
import ejs from 'ejs';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { type HtmlSafeString, unsafeHtml } from '@prairielearn/html';
|
|
7
7
|
/**
|
|
8
8
|
* This is a shim to allow for the use of EJS templates inside of HTML tagged
|
|
9
9
|
* template literals.
|