ecto 1.2.3 → 2.0.2
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 +1 -1
- package/README.md +59 -91
- package/dist/ecto.d.ts +0 -1
- package/dist/ecto.js +1 -5
- package/dist/ecto.js.map +1 -1
- package/dist/engines/markdown.js +5 -15
- package/dist/engines/markdown.js.map +1 -1
- package/package.json +10 -10
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, Mustache, and Handlebars
|
|
4
4
|
|
|
5
|
-
[](https://github.com/jaredwray/ecto/actions)
|
|
6
|
+
[](https://github.com/jaredwray/ecto/actions)
|
|
7
7
|
[](https://github.com/jaredwray/ecto/blob/master/LICENSE)
|
|
8
8
|
[](https://codecov.io/gh/jaredwray/ecto)
|
|
9
9
|
[](https://npmjs.com/package/ecto)
|
|
@@ -24,46 +24,27 @@ Ecto is a modern template consolidation engine that works with the top template
|
|
|
24
24
|
|
|
25
25
|
## Getting Started
|
|
26
26
|
|
|
27
|
-
Follow these steps to add Ecto to a new or existing JavaScript project:
|
|
28
|
-
|
|
29
|
-
1. Ensure Node.js is installed. For macOS and Linux, you can install Node.js in the terminal using Homebrew:
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
brew install node
|
|
33
|
-
```
|
|
34
|
-
|
|
35
27
|
The [Node.js package manager documentation](https://nodejs.org/en/download/package-manager/) provides the commands needed to complete the install on Windows and other operating systems.
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
npm install
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
3. Add Ecto to your Project. `yarn` is a package manager you can learn about [here.](https://yarnpkg.com/)
|
|
29
|
+
1. Open the terminal for your project and run `npm install` to ensure all project dependencies are correctly installed.
|
|
44
30
|
|
|
45
31
|
```
|
|
46
|
-
|
|
32
|
+
npm install ecto
|
|
47
33
|
```
|
|
48
34
|
|
|
49
|
-
|
|
35
|
+
2. Declare and Initialize.
|
|
50
36
|
|
|
51
37
|
```javascript
|
|
52
|
-
|
|
53
|
-
let ecto = new Ecto();
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
OR
|
|
38
|
+
import { Ecto } from `ecto`;
|
|
57
39
|
|
|
58
|
-
|
|
59
|
-
const ecto = require("ecto").create();
|
|
40
|
+
const ecto = new Ecto();
|
|
60
41
|
```
|
|
61
42
|
|
|
62
43
|
5. Render via String for EJS ([Default Engine](#default-engine))
|
|
63
44
|
|
|
64
45
|
```javascript
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
const source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
|
|
47
|
+
const data = {firstName: "John", lastName: "Doe"}
|
|
67
48
|
ecto.render(source, data).then((output) => {
|
|
68
49
|
console.log(output);
|
|
69
50
|
});
|
|
@@ -140,8 +121,7 @@ _The `Extensions` are listed above for when we [Render from File](#render-from-f
|
|
|
140
121
|
The API is focused on using the main Ecto class:
|
|
141
122
|
|
|
142
123
|
```javascript
|
|
143
|
-
const
|
|
144
|
-
let ecto = new Ecto();
|
|
124
|
+
const ecto = new Ecto();
|
|
145
125
|
//ecto.<API> -- functions and parameters
|
|
146
126
|
```
|
|
147
127
|
|
|
@@ -170,10 +150,10 @@ render (`async`) - Render from a string. Here is the render function with all po
|
|
|
170
150
|
Here is the simplest example of a render function. We are also showing the required steps you need to take beforehand such as setting up Ecto.
|
|
171
151
|
|
|
172
152
|
```javascript
|
|
173
|
-
|
|
153
|
+
const ecto = new Ecto();
|
|
174
154
|
|
|
175
|
-
|
|
176
|
-
|
|
155
|
+
const source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
|
|
156
|
+
const data = {firstName: "John", lastName: "Doe"};
|
|
177
157
|
ecto.render(source, data).then((output) => {
|
|
178
158
|
console.log(output);
|
|
179
159
|
});
|
|
@@ -182,10 +162,10 @@ ecto.render(source, data).then((output) => {
|
|
|
182
162
|
Now let's say your desired engine is not [EJS](https://www.npmjs.com/package/ejs), you will need to specify it explicitly. You can either set the [defaultEngine](#default-engine) parameter, or simply pass it in the `render` function. In this case with the popular engine, [Handlebars](https://www.npmjs.com/package/handlebars):
|
|
183
163
|
|
|
184
164
|
```javascript
|
|
185
|
-
|
|
165
|
+
const ecto = new Ecto();
|
|
186
166
|
|
|
187
|
-
|
|
188
|
-
|
|
167
|
+
const source = "<h1>Hello {{firstName}} {{lastName}}!</h1>";
|
|
168
|
+
const data = {firstName: "John", lastName: "Doe"}
|
|
189
169
|
ecto.render(source, data, "handlebars").then((output) => {
|
|
190
170
|
console.log(output);
|
|
191
171
|
});
|
|
@@ -195,10 +175,10 @@ ecto.render(source, data, "handlebars").then((output) => {
|
|
|
195
175
|
The `render` function also can handle partial files for standard engines (markdown excluded) by simply adding the `rootTemplatePath`:
|
|
196
176
|
|
|
197
177
|
```javascript
|
|
198
|
-
|
|
178
|
+
const ecto = new Ecto();
|
|
199
179
|
|
|
200
|
-
|
|
201
|
-
|
|
180
|
+
const source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1><%- include('/relative/path/to/partial'); %>";
|
|
181
|
+
const data = {firstName: "John", lastName: "Doe"};
|
|
202
182
|
ecto.render(source, data, undefined, "./path/to/templates").then((output) => {
|
|
203
183
|
console.log(output);
|
|
204
184
|
});
|
|
@@ -208,10 +188,10 @@ ecto.render(source, data, undefined, "./path/to/templates").then((output) => {
|
|
|
208
188
|
With `render` you can also write to a file. This is accomplished by specifying the `filePathOutput` parameter as below. It will still return the output as a `string`:
|
|
209
189
|
|
|
210
190
|
```javascript
|
|
211
|
-
|
|
191
|
+
const ecto = new Ecto();
|
|
212
192
|
|
|
213
|
-
|
|
214
|
-
|
|
193
|
+
const source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
|
|
194
|
+
const data = {firstName: "John", lastName: "Doe"};
|
|
215
195
|
ecto.render(source, data, undefined, undefined, "./path/to/output/file.html").then((output) => {
|
|
216
196
|
console.log(output);
|
|
217
197
|
});
|
|
@@ -240,16 +220,16 @@ This simple example showing the `renderFromFile` function shows you the bare min
|
|
|
240
220
|
One of the main benefits is that it will automatically select the correct engine based on the file extension.
|
|
241
221
|
|
|
242
222
|
```javascript
|
|
243
|
-
|
|
244
|
-
|
|
223
|
+
const ecto = new Ecto();
|
|
224
|
+
const data = { firstName: "John", lastName: "Doe"};
|
|
245
225
|
|
|
246
226
|
ecto.renderFromFile("./path/to/template.ejs", data).then((output) => {console.log(output)});
|
|
247
227
|
```
|
|
248
228
|
In this example, we are writing the output to a HTML file:
|
|
249
229
|
|
|
250
230
|
```javascript
|
|
251
|
-
|
|
252
|
-
|
|
231
|
+
const ecto = new Ecto();
|
|
232
|
+
const data = { firstName: "John", lastName: "Doe"};
|
|
253
233
|
|
|
254
234
|
ecto.renderFromFile("./path/to/template.ejs", data, undefined, "./path/to/output/yourname.html")
|
|
255
235
|
```
|
|
@@ -259,8 +239,8 @@ Notice that in these examples it is using the `./path/to/template.ejs` to specif
|
|
|
259
239
|
You can override the auto-selected engine by passing in the string value of a template engine as a parameter into the `renderFromFile` function. We pass in `pug`, which states we want to render the template using the [Pug](https://www.npmjs.com/package/pug) engine.
|
|
260
240
|
|
|
261
241
|
```javascript
|
|
262
|
-
|
|
263
|
-
|
|
242
|
+
const ecto = new Ecto();
|
|
243
|
+
const data = { firstName: "John", lastName: "Doe"};
|
|
264
244
|
|
|
265
245
|
ecto.renderFromFile("./path/to/template.ejs", data, undefined,
|
|
266
246
|
"./path/to/output/yourname.html", "pug")
|
|
@@ -276,29 +256,27 @@ This string parameter can be used to set the default template engine for an inst
|
|
|
276
256
|
|
|
277
257
|
One option for setting the default engine, is to do so in the Ecto constructor:
|
|
278
258
|
|
|
279
|
-
- `const ecto =
|
|
280
|
-
- `const ecto =
|
|
281
|
-
- `const ecto =
|
|
282
|
-
- `const ecto =
|
|
283
|
-
- `const ecto =
|
|
284
|
-
- `const ecto =
|
|
285
|
-
- `const ecto =
|
|
259
|
+
- `const ecto = new Ecto({defaultEngine: "ejs"});`
|
|
260
|
+
- `const ecto = new Ecto({defaultEngine: "markdown"});`
|
|
261
|
+
- `const ecto = new Ecto({defaultEngine: "pug"});`
|
|
262
|
+
- `const ecto = new Ecto({defaultEngine: "nunjucks"});`
|
|
263
|
+
- `const ecto = new Ecto({defaultEngine: "mustache"});`
|
|
264
|
+
- `const ecto = new Ecto({defaultEngine: "handlebars"});`
|
|
265
|
+
- `const ecto = new Ecto({defaultEngine: "liquid"});`
|
|
286
266
|
|
|
287
267
|
##### Set the default engine as a parameter
|
|
288
268
|
|
|
289
269
|
We can also set the default engine as a parameter, like so:
|
|
290
270
|
|
|
291
271
|
```javascript
|
|
292
|
-
const
|
|
293
|
-
let ecto = new Ecto();
|
|
272
|
+
const ecto = new Ecto();
|
|
294
273
|
ecto.defaultEngine = "mustache";
|
|
295
274
|
```
|
|
296
275
|
|
|
297
276
|
Alternatively, we can set the engine directly on the constructor. This would make our previous example:
|
|
298
277
|
|
|
299
278
|
```javascript
|
|
300
|
-
const
|
|
301
|
-
let ecto = new Ecto({defaultEngine: "liquid"});
|
|
279
|
+
const ecto = new Ecto({defaultEngine: "liquid"});
|
|
302
280
|
ecto.defaultEngine = "mustache";
|
|
303
281
|
```
|
|
304
282
|
|
|
@@ -307,9 +285,9 @@ ecto.defaultEngine = "mustache";
|
|
|
307
285
|
You can explicitly override the Ecto.defaultEngine parameter in the render function:
|
|
308
286
|
|
|
309
287
|
```javascript
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
288
|
+
const ecto = new Ecto();
|
|
289
|
+
const source = "<h1>Hello {{firstName}} {{lastName}}!</h1>";
|
|
290
|
+
const data = {firstName: "John", lastName: "Doe"};
|
|
313
291
|
ecto.render(source, data, "handlebars").then((output) => {
|
|
314
292
|
console.log(output);
|
|
315
293
|
});
|
|
@@ -320,8 +298,8 @@ ecto.render(source, data, "handlebars").then((output) => {
|
|
|
320
298
|
The `renderFromFile` function automatically decides on the template engine, based on the file extension in the file path you specify. However, you can also explicitly set the engine you would like to use. Here we set the engine to be Pug.
|
|
321
299
|
|
|
322
300
|
```javascript
|
|
323
|
-
|
|
324
|
-
|
|
301
|
+
const ecto = new Ecto();
|
|
302
|
+
const data = { firstName: "John", lastName: "Doe"};
|
|
325
303
|
ecto.renderFromFile("./path/to/template.ejs", data, undefined, "./path/to/output/yourname.html", "pug").then((output) => {
|
|
326
304
|
console.log(output)
|
|
327
305
|
});
|
|
@@ -330,7 +308,7 @@ ecto.renderFromFile("./path/to/template.ejs", data, undefined, "./path/to/output
|
|
|
330
308
|
To make it easier to access and change between engines, all supported engines are provided as parameters on the `Ecto` class as `Ecto.<EngineFullName>`
|
|
331
309
|
|
|
332
310
|
```javascript
|
|
333
|
-
|
|
311
|
+
const ecto = Ecto();
|
|
334
312
|
console.log(ecto.Handlebars.name); // will return "handlebars"
|
|
335
313
|
console.log(ecto.Handlebars.opts); // will return "handlebars" options object
|
|
336
314
|
```
|
|
@@ -338,7 +316,7 @@ console.log(ecto.Handlebars.opts); // will return "handlebars" options object
|
|
|
338
316
|
To access a specific engine you can do so by going to `ecto.<engine_name>.engine` and setting the [SafeString](https://handlebarsjs.com/api-reference/utilities.html#handlebars-safestring-string):
|
|
339
317
|
|
|
340
318
|
```javascript
|
|
341
|
-
|
|
319
|
+
const ecto = Ecto();
|
|
342
320
|
ecto.Handlebars.engine.SafeString("<div>HTML Content!</div>");
|
|
343
321
|
```
|
|
344
322
|
|
|
@@ -350,9 +328,9 @@ import { Ecto } from "ecto";
|
|
|
350
328
|
|
|
351
329
|
and then simply call it like you do with standard javascript:
|
|
352
330
|
```javascript
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
331
|
+
const ecto = Ecto();
|
|
332
|
+
const source = "# markdown rulezz!";
|
|
333
|
+
const output = await ecto.render(source, undefined, "markdown");
|
|
356
334
|
console.log(output) //should be <h1 id="markdown-rulezz">markdown rulezz!</h1>
|
|
357
335
|
```
|
|
358
336
|
_NOTE: this example would be in an `async` function._
|
|
@@ -365,8 +343,8 @@ _NOTE: this example would be in an `async` function._
|
|
|
365
343
|
Markdown does not contain complexities such as data objects, or partials and layouts. To render markdown its as simple as:
|
|
366
344
|
|
|
367
345
|
```javascript
|
|
368
|
-
|
|
369
|
-
|
|
346
|
+
const ecto = Ecto();
|
|
347
|
+
const source = "# markdown rulezz!";
|
|
370
348
|
ecto.render(source, undefined, "markdown").then((output) => {
|
|
371
349
|
console.log(output) //should be <h1 id="markdown-rulezz">markdown rulezz!</h1>
|
|
372
350
|
});
|
|
@@ -374,25 +352,13 @@ ecto.render(source, undefined, "markdown").then((output) => {
|
|
|
374
352
|
Render by Markdown file:
|
|
375
353
|
|
|
376
354
|
```javascript
|
|
377
|
-
|
|
355
|
+
const ecto = Ecto();
|
|
378
356
|
ecto.renderByFile("/path/to/file.md").then((output) => {
|
|
379
357
|
console.log(output)
|
|
380
358
|
});
|
|
381
359
|
```
|
|
382
360
|
|
|
383
|
-
|
|
384
|
-
```javascript
|
|
385
|
-
{
|
|
386
|
-
pedantic: false,
|
|
387
|
-
gfm: true,
|
|
388
|
-
breaks: false,
|
|
389
|
-
sanitize: false,
|
|
390
|
-
smartLists: true,
|
|
391
|
-
smartypants: false,
|
|
392
|
-
xhtml: false
|
|
393
|
-
}
|
|
394
|
-
```
|
|
395
|
-
You can read more about them [here](https://marked.js.org/using_advanced#options).
|
|
361
|
+
We are using [Markdoc](https://markdoc.io/) which has a ton of powerful features.
|
|
396
362
|
|
|
397
363
|
#### Handlebars
|
|
398
364
|
|
|
@@ -401,8 +367,8 @@ In Ecto we use the [handlebars](https://www.npmjs.com/package/handlebars-helpers
|
|
|
401
367
|
Handlebars is a fantastic template engine, and we've incorporated helpers to make it even better. We added in [handlebars-helpers](https://www.npmjs.com/package/handlebars-helpers) so you can format dates, and more. Here is an example using `Handlebars Helpers` in your template:
|
|
402
368
|
|
|
403
369
|
```javascript
|
|
404
|
-
|
|
405
|
-
|
|
370
|
+
const ecto = Ecto();
|
|
371
|
+
const source = "{{year}}";
|
|
406
372
|
|
|
407
373
|
ecto.render(source, undefined, "handlebars").then((output) => {
|
|
408
374
|
console.log(output)
|
|
@@ -520,8 +486,6 @@ Issues can be used to keep track of bugs, enhancements, or other requests. Issue
|
|
|
520
486
|
3. Click New Issue.
|
|
521
487
|
4. Enter the title and description for your issue, and click "Submit new issue".
|
|
522
488
|
|
|
523
|
-
|
|
524
|
-
|
|
525
489
|
## The Template Engines we support
|
|
526
490
|
|
|
527
491
|
### What is a Template Engine?
|
|
@@ -612,8 +576,8 @@ Handlebars is a fantastic template engine, and we've incorporated helpers to mak
|
|
|
612
576
|
|
|
613
577
|
|
|
614
578
|
```javascript
|
|
615
|
-
|
|
616
|
-
|
|
579
|
+
const ecto = Ecto();
|
|
580
|
+
const source = "{{year}}";
|
|
617
581
|
|
|
618
582
|
ecto.render(source, undefined, "handlebars").then((output) => {
|
|
619
583
|
console.log(output)
|
|
@@ -629,3 +593,7 @@ Liquid, like the previous template engines, creates a bridge between an HTML fil
|
|
|
629
593
|
Liquid files have the extension of `.liquid`. A liquid file is a mix of standard HTML code and Liquid constructs. Its clear syntax is easy to distinguish from HTML when working with a Liquid file. This is made even easier thanks to the use of two sets of delimiters.
|
|
630
594
|
|
|
631
595
|
The double curly brace delimiters `{{ }}` denote output, and the curly brace percentage delimiters `{% %}` denote logic. You'll become very familiar with these as every Liquid construct begins with one, or the other. Another way of thinking of delimiters is as placeholders. A placeholder can be viewed as a piece of code that will ultimately be replaced by data when the compiled file is sent to the browser.
|
|
596
|
+
|
|
597
|
+
# License
|
|
598
|
+
|
|
599
|
+
[MIT License - Copyright (c) 2021-2022 Jared Wray](LICENSE)
|
package/dist/ecto.d.ts
CHANGED
package/dist/ecto.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Ecto = void 0;
|
|
4
4
|
const engineMap_1 = require("./engineMap");
|
|
5
5
|
const markdown_1 = require("./engines/markdown");
|
|
6
6
|
const handlebars_1 = require("./engines/handlebars");
|
|
@@ -164,8 +164,4 @@ class Ecto {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
exports.Ecto = Ecto;
|
|
167
|
-
function create(opts) {
|
|
168
|
-
return new Ecto(opts);
|
|
169
|
-
}
|
|
170
|
-
exports.create = create;
|
|
171
167
|
//# sourceMappingURL=ecto.js.map
|
package/dist/ecto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecto.js","sourceRoot":"","sources":["../src/ecto.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,iDAA8C;AAC9C,qDAAkD;AAClD,uCAAoC;AACpC,uCAAoC;AACpC,iDAA8C;AAC9C,6CAA0C;AAE1C,+BAA+B;AAE/B,MAAa,IAAI;IAeb,YAAY,IAAS;QAbb,cAAS,GAAc,IAAI,qBAAS,EAAE,CAAC;QACvC,cAAS,GAAsB,IAAI,KAAK,EAAc,CAAC;QAEvD,oBAAe,GAAW,KAAK,CAAC;QAExC,SAAS;QACD,UAAK,GAAQ,IAAI,SAAG,EAAE,CAAC;QACvB,eAAU,GAAa,IAAI,mBAAQ,EAAE,CAAC;QACtC,UAAK,GAAQ,IAAI,SAAG,EAAE,CAAC;QACvB,eAAU,GAAa,IAAI,mBAAQ,EAAE,CAAC;QACtC,iBAAY,GAAe,IAAI,uBAAU,EAAE,CAAC;QAC5C,aAAQ,GAAW,IAAI,eAAM,EAAE,CAAC;QAIpC,kBAAkB;QAClB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,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,CAAC,YAAY,CAAC;gBAC3B,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;gBACvB,MAAM;SACb;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAtMD,oBAsMC"}
|
package/dist/engines/markdown.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Markdown = void 0;
|
|
4
4
|
const baseEngine_1 = require("../baseEngine");
|
|
5
|
-
const
|
|
5
|
+
const markdoc_1 = require("@markdoc/markdoc");
|
|
6
6
|
class Markdown extends baseEngine_1.BaseEngine {
|
|
7
7
|
constructor(opts) {
|
|
8
8
|
super();
|
|
@@ -10,23 +10,13 @@ class Markdown extends baseEngine_1.BaseEngine {
|
|
|
10
10
|
if (opts) {
|
|
11
11
|
this.opts = opts;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
this.opts = {
|
|
15
|
-
pedantic: false,
|
|
16
|
-
gfm: true,
|
|
17
|
-
breaks: false,
|
|
18
|
-
sanitize: false,
|
|
19
|
-
smartLists: true,
|
|
20
|
-
smartypants: false,
|
|
21
|
-
xhtml: false
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
this.engine = marked_1.marked;
|
|
25
|
-
this.engine.setOptions(this.opts);
|
|
13
|
+
this.engine = markdoc_1.default;
|
|
26
14
|
this.setExtensions(["md", "markdown"]);
|
|
27
15
|
}
|
|
28
16
|
async render(source, data) {
|
|
29
|
-
|
|
17
|
+
const ast = this.engine.parse(source);
|
|
18
|
+
const content = this.engine.transform(ast, this.opts);
|
|
19
|
+
return this.engine.renderers.html(content);
|
|
30
20
|
}
|
|
31
21
|
}
|
|
32
22
|
exports.Markdown = Markdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/engines/markdown.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/engines/markdown.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,8CAAuC;AAEvC,MAAa,QAAS,SAAQ,uBAAU;IAEpC,YAAY,IAAS;QACjB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,CAAC,UAAU,CAAC,CAAC;QAE1B,IAAG,IAAI,EAAE;YACL,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SACpB;QAED,IAAI,CAAC,MAAM,GAAG,iBAAO,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAa,EAAE,IAAY;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACJ;AArBD,4BAqBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecto",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, and Handlebars",
|
|
5
5
|
"main": "./dist/ecto.js",
|
|
6
6
|
"types": "./dist/ecto.d.ts",
|
|
@@ -35,32 +35,32 @@
|
|
|
35
35
|
"build": "rm -rf ./dist && npm i && npm run test && npm run compile"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@markdoc/markdoc": "^0.1.4",
|
|
38
39
|
"ejs": "^3.1.8",
|
|
39
40
|
"fs-extra": "^10.1.0",
|
|
40
41
|
"handlebars": "^4.7.7",
|
|
41
42
|
"handlebars-helpers": "^0.10.0",
|
|
42
43
|
"helper-date": "^1.0.1",
|
|
43
|
-
"liquidjs": "^9.
|
|
44
|
-
"marked": "^4.0.16",
|
|
44
|
+
"liquidjs": "^9.39.1",
|
|
45
45
|
"nunjucks": "^3.2.3",
|
|
46
46
|
"pug": "^3.0.2",
|
|
47
|
-
"underscore": "^1.13.
|
|
48
|
-
"winston": "^3.
|
|
47
|
+
"underscore": "^1.13.4",
|
|
48
|
+
"winston": "^3.8.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/ejs": "^3.1.1",
|
|
52
52
|
"@types/express": "^4.17.13",
|
|
53
53
|
"@types/fs-extra": "^9.0.13",
|
|
54
54
|
"@types/handlebars-helpers": "^0.5.3",
|
|
55
|
-
"@types/jest": "^
|
|
55
|
+
"@types/jest": "^28.1.6",
|
|
56
56
|
"@types/marked": "^4.0.3",
|
|
57
|
-
"@types/mustache": "^4.
|
|
57
|
+
"@types/mustache": "^4.2.0",
|
|
58
58
|
"@types/nunjucks": "^3.2.1",
|
|
59
59
|
"@types/pug": "^2.0.6",
|
|
60
60
|
"@types/underscore": "^1.11.4",
|
|
61
|
-
"jest": "^28.1.
|
|
62
|
-
"ts-jest": "^28.0.
|
|
63
|
-
"typescript": "^4.
|
|
61
|
+
"jest": "^28.1.3",
|
|
62
|
+
"ts-jest": "^28.0.7",
|
|
63
|
+
"typescript": "^4.7.4"
|
|
64
64
|
},
|
|
65
65
|
"files": [
|
|
66
66
|
"dist",
|