ecto 1.2.3 → 2.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Jared Wray
3
+ Copyright (c) 2021-2022 Jared Wray
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
- [![Build Status](https://github.com/jaredwray/ecto/workflows/ecto-build/badge.svg)](https://github.com/jaredwray/ecto/actions)
6
- [![Release Status](https://github.com/jaredwray/ecto/workflows/ecto-release/badge.svg)](https://github.com/jaredwray/ecto/actions)
5
+ [![Build Status](https://github.com/jaredwray/ecto/workflows/build/badge.svg)](https://github.com/jaredwray/ecto/actions)
6
+ [![Release Status](https://github.com/jaredwray/ecto/workflows/release/badge.svg)](https://github.com/jaredwray/ecto/actions)
7
7
  [![GitHub license](https://img.shields.io/github/license/jaredwray/ecto)](https://github.com/jaredwray/ecto/blob/master/LICENSE)
8
8
  [![codecov](https://codecov.io/gh/jaredwray/ecto/branch/main/graph/badge.svg?token=dpbFqSW5Kh)](https://codecov.io/gh/jaredwray/ecto)
9
9
  [![npm](https://img.shields.io/npm/dm/ecto)](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
- 2. Open the terminal for your project and run `npm install ` to ensure all project dependencies are correctly installed.
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
- yarn add ecto
32
+ npm install ecto
47
33
  ```
48
34
 
49
- 4. Declare and Initialize.
35
+ 2. Declare and Initialize.
50
36
 
51
37
  ```javascript
52
- const Ecto = require("ecto").Ecto;
53
- let ecto = new Ecto();
54
- ```
55
-
56
- OR
38
+ import { Ecto } from `ecto`;
57
39
 
58
- ```javascript
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
- let source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
66
- let data = {firstName: "John", lastName: "Doe"}
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 Ecto = require("Ecto").Ecto;
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
- let ecto = require("ecto").create();
153
+ const ecto = new Ecto();
174
154
 
175
- let source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
176
- let data = {firstName: "John", lastName: "Doe"};
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
- let ecto = require("ecto").create();
165
+ const ecto = new Ecto();
186
166
 
187
- let source = "<h1>Hello {{firstName}} {{lastName}}!</h1>";
188
- let data = {firstName: "John", lastName: "Doe"}
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
- let ecto = require("ecto").create();
178
+ const ecto = new Ecto();
199
179
 
200
- let source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1><%- include('/relative/path/to/partial'); %>";
201
- let data = {firstName: "John", lastName: "Doe"};
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
- let ecto = require("ecto").create();
191
+ const ecto = new Ecto();
212
192
 
213
- let source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
214
- let data = {firstName: "John", lastName: "Doe"};
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
- let ecto = require("ecto").create();
244
- let data = { firstName: "John", lastName: "Doe"};
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
- let ecto = require("ecto").create();
252
- let data = { firstName: "John", lastName: "Doe"};
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
- let ecto = require("ecto").create();
263
- let data = { firstName: "John", lastName: "Doe"};
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 = require("ecto").create({defaultEngine: "ejs"});`
280
- - `const ecto = require("ecto").create({defaultEngine: "markdown"});`
281
- - `const ecto = require("ecto").create({defaultEngine: "pug"});`
282
- - `const ecto = require("ecto").create({defaultEngine: "nunjucks"});`
283
- - `const ecto = require("ecto").create({defaultEngine: "mustache"});`
284
- - `const ecto = require("ecto").create({defaultEngine: "handlebars"});`
285
- - `const ecto = require("ecto").create({defaultEngine: "liquid"});`
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 Ecto = require("ecto").Ecto;
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 Ecto = require("ecto").Ecto;
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
- let ecto = require("ecto").create();
311
- let source = "<h1>Hello {{firstName}} {{lastName}}!</h1>";
312
- let data = {firstName: "John", lastName: "Doe"};
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
- let ecto = new Ecto();
324
- let data = { firstName: "John", lastName: "Doe"};
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
- let ecto = Ecto();
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
- let ecto = Ecto();
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
- let ecto = Ecto();
354
- let source = "# markdown rulezz!";
355
- let output = await ecto.render(source, undefined, "markdown");
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
- let ecto = Ecto();
369
- let source = "# markdown rulezz!";
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
- let ecto = Ecto();
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
- With Markdown we have added the following options as they are the most common:
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
- let ecto = Ecto();
405
- let source = "{{year}}";
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
- let ecto = Ecto();
616
- let source = "{{year}}";
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
@@ -34,4 +34,3 @@ export declare class Ecto {
34
34
  registerEngineMappings(): void;
35
35
  getRenderEngine(engineName: string): EngineInterface;
36
36
  }
37
- export declare function create(opts?: any): Ecto;
package/dist/ecto.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = exports.Ecto = void 0;
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;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B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAEzB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,eAAe,CAAC,UAAiB;QAC7B,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,iBAAiB;QAE1C,QAAO,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAC;YACnC,KAAK,UAAU;gBACX,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;gBACzB,MAAM;YACV,KAAK,KAAK;gBACN,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;gBACpB,MAAM;YACV,KAAK,UAAU;gBACX,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;gBACzB,MAAM;YACV,KAAK,UAAU;gBACX,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;gBAC3B,MAAM;YACV,KAAK,YAAY;gBACb,MAAM,GAAG,IAAI,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"}
@@ -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 marked_1 = require("marked");
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
- else {
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
- return this.engine.parse(source);
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,mCAAgC;AAEhC,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;aAAM;YACH,IAAI,CAAC,IAAI,GAAG;gBACR,QAAQ,EAAE,KAAK;gBACf,GAAG,EAAE,IAAI;gBACT,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,IAAI;gBAChB,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,KAAK;aACb,CAAC;SACP;QAED,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC;QAErB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAa,EAAE,IAAY;QAEpC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACJ;AAhCD,4BAgCC"}
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,9 +1,10 @@
1
1
  {
2
2
  "name": "ecto",
3
- "version": "1.2.3",
3
+ "version": "2.0.0",
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",
7
+ "type": "module",
7
8
  "repository": "https://github.com/jaredwray/ecto.git",
8
9
  "author": "Jared Wray <me@jaredwray.com>",
9
10
  "license": "MIT",
@@ -35,16 +36,16 @@
35
36
  "build": "rm -rf ./dist && npm i && npm run test && npm run compile"
36
37
  },
37
38
  "dependencies": {
39
+ "@markdoc/markdoc": "^0.1.2",
38
40
  "ejs": "^3.1.8",
39
41
  "fs-extra": "^10.1.0",
40
42
  "handlebars": "^4.7.7",
41
43
  "handlebars-helpers": "^0.10.0",
42
44
  "helper-date": "^1.0.1",
43
45
  "liquidjs": "^9.37.0",
44
- "marked": "^4.0.16",
45
46
  "nunjucks": "^3.2.3",
46
47
  "pug": "^3.0.2",
47
- "underscore": "^1.13.3",
48
+ "underscore": "^1.13.4",
48
49
  "winston": "^3.7.2"
49
50
  },
50
51
  "devDependencies": {
@@ -52,15 +53,15 @@
52
53
  "@types/express": "^4.17.13",
53
54
  "@types/fs-extra": "^9.0.13",
54
55
  "@types/handlebars-helpers": "^0.5.3",
55
- "@types/jest": "^27.5.1",
56
+ "@types/jest": "^28.1.1",
56
57
  "@types/marked": "^4.0.3",
57
- "@types/mustache": "^4.1.2",
58
+ "@types/mustache": "^4.1.3",
58
59
  "@types/nunjucks": "^3.2.1",
59
60
  "@types/pug": "^2.0.6",
60
61
  "@types/underscore": "^1.11.4",
61
- "jest": "^28.1.0",
62
- "ts-jest": "^28.0.2",
63
- "typescript": "^4.6.4"
62
+ "jest": "^28.1.1",
63
+ "ts-jest": "^28.0.4",
64
+ "typescript": "^4.7.3"
64
65
  },
65
66
  "files": [
66
67
  "dist",