minijinja-js 2.12.0 → 2.13.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/README.md CHANGED
@@ -46,6 +46,38 @@ const result = env.renderTemplate('index.html', { name: 'World' });
46
46
  console.log(result);
47
47
  ```
48
48
 
49
+ Resolve includes/extends from the filesystem (Node, etc...):
50
+
51
+ ```typescript
52
+ import { Environment } from "minijinja-js";
53
+ import fs from "node:fs";
54
+ import path from "node:path";
55
+
56
+ const env = new Environment();
57
+
58
+ // Resolve relative paths like "./partial.html" against the parent template
59
+ env.setPathJoinCallback((name, parent) => {
60
+ const parentDir = parent ? path.dirname(parent) : process.cwd();
61
+ const joined = path.resolve(parentDir, name);
62
+ return joined.replace(/\\\\/g, '/');
63
+ });
64
+
65
+ // Synchronous loader: return template source or null/undefined if missing
66
+ env.setLoader((name) => {
67
+ try {
68
+ return fs.readFileSync(name, "utf8");
69
+ } catch {
70
+ return null;
71
+ }
72
+ });
73
+
74
+ // Example: main in-memory, include from disk under ./templates/dir/inc.html
75
+ const templatePath = path.resolve(process.cwd(), "templates/dir/main.html");
76
+ env.addTemplate(templatePath, "Hello {% include './inc.html' %}!");
77
+ console.log(env.renderTemplate(templatePath, { value: "World" }));
78
+ // -> Hello [World]!
79
+ ```
80
+
49
81
  Evaluate an expression:
50
82
 
51
83
  ```typescript
@@ -74,6 +106,7 @@ others probably not so much. You might run into the following:
74
106
 
75
107
  * Access of the template engine state from JavaScript is not possible.
76
108
  * You cannot register a custom auto escape callback or a finalizer
109
+ * The loader is synchronous; use sync I/O in Node etc... (e.g. `fs.readFileSync`)
77
110
  * If the engine panics, the WASM runtime corrupts.
78
111
 
79
112
  ## Sponsor
@@ -46,6 +46,38 @@ const result = env.renderTemplate('index.html', { name: 'World' });
46
46
  console.log(result);
47
47
  ```
48
48
 
49
+ Resolve includes/extends from the filesystem (Node, etc...):
50
+
51
+ ```typescript
52
+ import { Environment } from "minijinja-js";
53
+ import fs from "node:fs";
54
+ import path from "node:path";
55
+
56
+ const env = new Environment();
57
+
58
+ // Resolve relative paths like "./partial.html" against the parent template
59
+ env.setPathJoinCallback((name, parent) => {
60
+ const parentDir = parent ? path.dirname(parent) : process.cwd();
61
+ const joined = path.resolve(parentDir, name);
62
+ return joined.replace(/\\\\/g, '/');
63
+ });
64
+
65
+ // Synchronous loader: return template source or null/undefined if missing
66
+ env.setLoader((name) => {
67
+ try {
68
+ return fs.readFileSync(name, "utf8");
69
+ } catch {
70
+ return null;
71
+ }
72
+ });
73
+
74
+ // Example: main in-memory, include from disk under ./templates/dir/inc.html
75
+ const templatePath = path.resolve(process.cwd(), "templates/dir/main.html");
76
+ env.addTemplate(templatePath, "Hello {% include './inc.html' %}!");
77
+ console.log(env.renderTemplate(templatePath, { value: "World" }));
78
+ // -> Hello [World]!
79
+ ```
80
+
49
81
  Evaluate an expression:
50
82
 
51
83
  ```typescript
@@ -74,6 +106,7 @@ others probably not so much. You might run into the following:
74
106
 
75
107
  * Access of the template engine state from JavaScript is not possible.
76
108
  * You cannot register a custom auto escape callback or a finalizer
109
+ * The loader is synchronous; use sync I/O in Node etc... (e.g. `fs.readFileSync`)
77
110
  * If the engine panics, the WASM runtime corrupts.
78
111
 
79
112
  ## Sponsor
@@ -6,34 +6,46 @@ type UndefinedBehavior = "strict" | "chainable" | "lenient" | "semi_strct";
6
6
  */
7
7
  export class Environment {
8
8
  free(): void;
9
- constructor();
10
9
  /**
11
10
  * Registers a new template by name and source.
12
11
  */
13
12
  addTemplate(name: string, source: string): void;
14
13
  /**
15
- * Removes a template by name.
14
+ * Removes a global again.
16
15
  */
17
- removeTemplate(name: string): void;
16
+ removeGlobal(name: string): void;
18
17
  /**
19
18
  * Clears all templates from the environment.
20
19
  */
21
20
  clearTemplates(): void;
21
+ /**
22
+ * Enables python compatibility.
23
+ */
24
+ enablePyCompat(): void;
25
+ /**
26
+ * Removes a template by name.
27
+ */
28
+ removeTemplate(name: string): void;
29
+ /**
30
+ * Like `renderStr` but with a named template for auto escape detection.
31
+ */
32
+ renderNamedStr(name: string, source: string, ctx: any): string;
22
33
  /**
23
34
  * Renders a registered template by name with the given context.
24
35
  */
25
36
  renderTemplate(name: string, ctx: any): string;
26
37
  /**
27
- * Renders a string template with the given context.
38
+ * Sets a callback to join template paths (for relative includes/extends).
28
39
  *
29
- * This is useful for one-off template rendering without registering the template. The
30
- * template is parsed and rendered immediately.
40
+ * The callback receives `(name, parent)` and should return a joined path string.
41
+ * If it throws or returns a non-string, the original `name` is used.
31
42
  */
32
- renderStr(source: string, ctx: any): string;
43
+ setPathJoinCallback(func: Function): void;
44
+ constructor();
33
45
  /**
34
- * Like `renderStr` but with a named template for auto escape detection.
46
+ * Registers a test function.
35
47
  */
36
- renderNamedStr(name: string, source: string, ctx: any): string;
48
+ addTest(name: string, func: Function): void;
37
49
  /**
38
50
  * Evaluates an expression with the given context.
39
51
  *
@@ -45,26 +57,25 @@ export class Environment {
45
57
  * Registers a filter function.
46
58
  */
47
59
  addFilter(name: string, func: Function): void;
48
- /**
49
- * Registers a test function.
50
- */
51
- addTest(name: string, func: Function): void;
52
- /**
53
- * Enables python compatibility.
54
- */
55
- enablePyCompat(): void;
56
60
  /**
57
61
  * Registers a value as global.
58
62
  */
59
63
  addGlobal(name: string, value: any): void;
60
64
  /**
61
- * Removes a global again.
65
+ * Renders a string template with the given context.
66
+ *
67
+ * This is useful for one-off template rendering without registering the template. The
68
+ * template is parsed and rendered immediately.
62
69
  */
63
- removeGlobal(name: string): void;
70
+ renderStr(source: string, ctx: any): string;
64
71
  /**
65
- * Enables or disables debug mode.
72
+ * Registers a synchronous template loader callback.
73
+ *
74
+ * The provided function is called with a template name and must return a
75
+ * string with the template source or `null`/`undefined` if the template
76
+ * does not exist. Errors thrown are propagated as MiniJinja errors.
66
77
  */
67
- debug: boolean;
78
+ setLoader(func: Function): void;
68
79
  /**
69
80
  * Enables or disables block trimming.
70
81
  */
@@ -73,17 +84,21 @@ export class Environment {
73
84
  * Enables or disables the lstrip blocks feature.
74
85
  */
75
86
  lstripBlocks: boolean;
76
- /**
77
- * Enables or disables keeping of the final newline.
78
- */
79
- keepTrailingNewline: boolean;
80
87
  /**
81
88
  * Reconfigures the behavior of undefined variables.
82
89
  */
83
90
  undefinedBehavior: UndefinedBehavior;
91
+ /**
92
+ * Enables or disables keeping of the final newline.
93
+ */
94
+ keepTrailingNewline: boolean;
84
95
  /**
85
96
  * Configures the max-fuel for template evaluation.
86
97
  */
87
98
  get fuel(): number | undefined;
88
99
  set fuel(value: number | null | undefined);
100
+ /**
101
+ * Enables or disables debug mode.
102
+ */
103
+ debug: boolean;
89
104
  }
@@ -218,11 +218,13 @@ export class Environment {
218
218
  const ptr = this.__destroy_into_raw();
219
219
  wasm.__wbg_environment_free(ptr, 0);
220
220
  }
221
- constructor() {
222
- const ret = wasm.environment_new();
223
- this.__wbg_ptr = ret >>> 0;
224
- EnvironmentFinalization.register(this, this.__wbg_ptr, this);
225
- return this;
221
+ /**
222
+ * Enables or disables block trimming.
223
+ * @returns {boolean}
224
+ */
225
+ get trimBlocks() {
226
+ const ret = wasm.environment_trimBlocks(this.__wbg_ptr);
227
+ return ret !== 0;
226
228
  }
227
229
  /**
228
230
  * Registers a new template by name and source.
@@ -247,13 +249,21 @@ export class Environment {
247
249
  }
248
250
  }
249
251
  /**
250
- * Removes a template by name.
252
+ * Enables or disables the lstrip blocks feature.
253
+ * @returns {boolean}
254
+ */
255
+ get lstripBlocks() {
256
+ const ret = wasm.environment_lstripBlocks(this.__wbg_ptr);
257
+ return ret !== 0;
258
+ }
259
+ /**
260
+ * Removes a global again.
251
261
  * @param {string} name
252
262
  */
253
- removeTemplate(name) {
263
+ removeGlobal(name) {
254
264
  const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
255
265
  const len0 = WASM_VECTOR_LEN;
256
- wasm.environment_removeTemplate(this.__wbg_ptr, ptr0, len0);
266
+ wasm.environment_removeGlobal(this.__wbg_ptr, ptr0, len0);
257
267
  }
258
268
  /**
259
269
  * Clears all templates from the environment.
@@ -262,71 +272,19 @@ export class Environment {
262
272
  wasm.environment_clearTemplates(this.__wbg_ptr);
263
273
  }
264
274
  /**
265
- * Renders a registered template by name with the given context.
266
- * @param {string} name
267
- * @param {any} ctx
268
- * @returns {string}
275
+ * Enables python compatibility.
269
276
  */
270
- renderTemplate(name, ctx) {
271
- let deferred3_0;
272
- let deferred3_1;
273
- try {
274
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
275
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
276
- const len0 = WASM_VECTOR_LEN;
277
- wasm.environment_renderTemplate(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(ctx));
278
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
279
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
280
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
281
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
282
- var ptr2 = r0;
283
- var len2 = r1;
284
- if (r3) {
285
- ptr2 = 0; len2 = 0;
286
- throw takeObject(r2);
287
- }
288
- deferred3_0 = ptr2;
289
- deferred3_1 = len2;
290
- return getStringFromWasm0(ptr2, len2);
291
- } finally {
292
- wasm.__wbindgen_add_to_stack_pointer(16);
293
- wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
294
- }
277
+ enablePyCompat() {
278
+ wasm.environment_enablePyCompat(this.__wbg_ptr);
295
279
  }
296
280
  /**
297
- * Renders a string template with the given context.
298
- *
299
- * This is useful for one-off template rendering without registering the template. The
300
- * template is parsed and rendered immediately.
301
- * @param {string} source
302
- * @param {any} ctx
303
- * @returns {string}
281
+ * Removes a template by name.
282
+ * @param {string} name
304
283
  */
305
- renderStr(source, ctx) {
306
- let deferred3_0;
307
- let deferred3_1;
308
- try {
309
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
310
- const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
311
- const len0 = WASM_VECTOR_LEN;
312
- wasm.environment_renderStr(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(ctx));
313
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
316
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
317
- var ptr2 = r0;
318
- var len2 = r1;
319
- if (r3) {
320
- ptr2 = 0; len2 = 0;
321
- throw takeObject(r2);
322
- }
323
- deferred3_0 = ptr2;
324
- deferred3_1 = len2;
325
- return getStringFromWasm0(ptr2, len2);
326
- } finally {
327
- wasm.__wbindgen_add_to_stack_pointer(16);
328
- wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
329
- }
284
+ removeTemplate(name) {
285
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
286
+ const len0 = WASM_VECTOR_LEN;
287
+ wasm.environment_removeTemplate(this.__wbg_ptr, ptr0, len0);
330
288
  }
331
289
  /**
332
290
  * Like `renderStr` but with a named template for auto escape detection.
@@ -364,99 +322,57 @@ export class Environment {
364
322
  }
365
323
  }
366
324
  /**
367
- * Evaluates an expression with the given context.
368
- *
369
- * This is useful for evaluating expressions outside of templates. The expression is
370
- * parsed and evaluated immediately.
371
- * @param {string} expr
325
+ * Renders a registered template by name with the given context.
326
+ * @param {string} name
372
327
  * @param {any} ctx
373
- * @returns {any}
328
+ * @returns {string}
374
329
  */
375
- evalExpr(expr, ctx) {
330
+ renderTemplate(name, ctx) {
331
+ let deferred3_0;
332
+ let deferred3_1;
376
333
  try {
377
334
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
378
- const ptr0 = passStringToWasm0(expr, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
335
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
379
336
  const len0 = WASM_VECTOR_LEN;
380
- wasm.environment_evalExpr(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(ctx));
337
+ wasm.environment_renderTemplate(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(ctx));
381
338
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
382
339
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
383
340
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
384
- if (r2) {
385
- throw takeObject(r1);
341
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
342
+ var ptr2 = r0;
343
+ var len2 = r1;
344
+ if (r3) {
345
+ ptr2 = 0; len2 = 0;
346
+ throw takeObject(r2);
386
347
  }
387
- return takeObject(r0);
348
+ deferred3_0 = ptr2;
349
+ deferred3_1 = len2;
350
+ return getStringFromWasm0(ptr2, len2);
388
351
  } finally {
389
352
  wasm.__wbindgen_add_to_stack_pointer(16);
353
+ wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
390
354
  }
391
355
  }
392
- /**
393
- * Registers a filter function.
394
- * @param {string} name
395
- * @param {Function} func
396
- */
397
- addFilter(name, func) {
398
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
399
- const len0 = WASM_VECTOR_LEN;
400
- wasm.environment_addFilter(this.__wbg_ptr, ptr0, len0, addHeapObject(func));
401
- }
402
- /**
403
- * Registers a test function.
404
- * @param {string} name
405
- * @param {Function} func
406
- */
407
- addTest(name, func) {
408
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
409
- const len0 = WASM_VECTOR_LEN;
410
- wasm.environment_addTest(this.__wbg_ptr, ptr0, len0, addHeapObject(func));
411
- }
412
- /**
413
- * Enables python compatibility.
414
- */
415
- enablePyCompat() {
416
- wasm.environment_enablePyCompat(this.__wbg_ptr);
417
- }
418
- /**
419
- * Enables or disables debug mode.
420
- * @returns {boolean}
421
- */
422
- get debug() {
423
- const ret = wasm.environment_debug(this.__wbg_ptr);
424
- return ret !== 0;
425
- }
426
- /**
427
- * @param {boolean} yes
428
- */
429
- set debug(yes) {
430
- wasm.environment_set_debug(this.__wbg_ptr, yes);
431
- }
432
- /**
433
- * Enables or disables block trimming.
434
- * @returns {boolean}
435
- */
436
- get trimBlocks() {
437
- const ret = wasm.environment_trimBlocks(this.__wbg_ptr);
438
- return ret !== 0;
439
- }
440
356
  /**
441
357
  * @param {boolean} yes
442
358
  */
443
359
  set trimBlocks(yes) {
444
360
  wasm.environment_set_trimBlocks(this.__wbg_ptr, yes);
445
361
  }
446
- /**
447
- * Enables or disables the lstrip blocks feature.
448
- * @returns {boolean}
449
- */
450
- get lstripBlocks() {
451
- const ret = wasm.environment_lstripBlocks(this.__wbg_ptr);
452
- return ret !== 0;
453
- }
454
362
  /**
455
363
  * @param {boolean} yes
456
364
  */
457
365
  set lstripBlocks(yes) {
458
366
  wasm.environment_set_lstripBlocks(this.__wbg_ptr, yes);
459
367
  }
368
+ /**
369
+ * Reconfigures the behavior of undefined variables.
370
+ * @returns {UndefinedBehavior}
371
+ */
372
+ get undefinedBehavior() {
373
+ const ret = wasm.environment_undefinedBehavior(this.__wbg_ptr);
374
+ return __wbindgen_enum_UndefinedBehavior[ret];
375
+ }
460
376
  /**
461
377
  * Enables or disables keeping of the final newline.
462
378
  * @returns {boolean}
@@ -466,18 +382,14 @@ export class Environment {
466
382
  return ret !== 0;
467
383
  }
468
384
  /**
469
- * @param {boolean} yes
470
- */
471
- set keepTrailingNewline(yes) {
472
- wasm.environment_set_keepTrailingNewline(this.__wbg_ptr, yes);
473
- }
474
- /**
475
- * Reconfigures the behavior of undefined variables.
476
- * @returns {UndefinedBehavior}
385
+ * Sets a callback to join template paths (for relative includes/extends).
386
+ *
387
+ * The callback receives `(name, parent)` and should return a joined path string.
388
+ * If it throws or returns a non-string, the original `name` is used.
389
+ * @param {Function} func
477
390
  */
478
- get undefinedBehavior() {
479
- const ret = wasm.environment_undefinedBehavior(this.__wbg_ptr);
480
- return __wbindgen_enum_UndefinedBehavior[ret];
391
+ setPathJoinCallback(func) {
392
+ wasm.environment_setPathJoinCallback(this.__wbg_ptr, addHeapObject(func));
481
393
  }
482
394
  /**
483
395
  * @param {UndefinedBehavior} value
@@ -495,6 +407,18 @@ export class Environment {
495
407
  wasm.__wbindgen_add_to_stack_pointer(16);
496
408
  }
497
409
  }
410
+ /**
411
+ * @param {boolean} yes
412
+ */
413
+ set keepTrailingNewline(yes) {
414
+ wasm.environment_set_keepTrailingNewline(this.__wbg_ptr, yes);
415
+ }
416
+ constructor() {
417
+ const ret = wasm.environment_new();
418
+ this.__wbg_ptr = ret >>> 0;
419
+ EnvironmentFinalization.register(this, this.__wbg_ptr, this);
420
+ return this;
421
+ }
498
422
  /**
499
423
  * Configures the max-fuel for template evaluation.
500
424
  * @returns {number | undefined}
@@ -503,12 +427,66 @@ export class Environment {
503
427
  const ret = wasm.environment_fuel(this.__wbg_ptr);
504
428
  return ret === 0x100000001 ? undefined : ret;
505
429
  }
430
+ /**
431
+ * Enables or disables debug mode.
432
+ * @returns {boolean}
433
+ */
434
+ get debug() {
435
+ const ret = wasm.environment_debug(this.__wbg_ptr);
436
+ return ret !== 0;
437
+ }
438
+ /**
439
+ * Registers a test function.
440
+ * @param {string} name
441
+ * @param {Function} func
442
+ */
443
+ addTest(name, func) {
444
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
445
+ const len0 = WASM_VECTOR_LEN;
446
+ wasm.environment_addTest(this.__wbg_ptr, ptr0, len0, addHeapObject(func));
447
+ }
448
+ /**
449
+ * Evaluates an expression with the given context.
450
+ *
451
+ * This is useful for evaluating expressions outside of templates. The expression is
452
+ * parsed and evaluated immediately.
453
+ * @param {string} expr
454
+ * @param {any} ctx
455
+ * @returns {any}
456
+ */
457
+ evalExpr(expr, ctx) {
458
+ try {
459
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
460
+ const ptr0 = passStringToWasm0(expr, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
461
+ const len0 = WASM_VECTOR_LEN;
462
+ wasm.environment_evalExpr(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(ctx));
463
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
464
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
465
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
466
+ if (r2) {
467
+ throw takeObject(r1);
468
+ }
469
+ return takeObject(r0);
470
+ } finally {
471
+ wasm.__wbindgen_add_to_stack_pointer(16);
472
+ }
473
+ }
506
474
  /**
507
475
  * @param {number | null} [value]
508
476
  */
509
477
  set fuel(value) {
510
478
  wasm.environment_set_fuel(this.__wbg_ptr, isLikeNone(value) ? 0x100000001 : (value) >>> 0);
511
479
  }
480
+ /**
481
+ * Registers a filter function.
482
+ * @param {string} name
483
+ * @param {Function} func
484
+ */
485
+ addFilter(name, func) {
486
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
487
+ const len0 = WASM_VECTOR_LEN;
488
+ wasm.environment_addFilter(this.__wbg_ptr, ptr0, len0, addHeapObject(func));
489
+ }
512
490
  /**
513
491
  * Registers a value as global.
514
492
  * @param {string} name
@@ -530,13 +508,56 @@ export class Environment {
530
508
  }
531
509
  }
532
510
  /**
533
- * Removes a global again.
534
- * @param {string} name
511
+ * Renders a string template with the given context.
512
+ *
513
+ * This is useful for one-off template rendering without registering the template. The
514
+ * template is parsed and rendered immediately.
515
+ * @param {string} source
516
+ * @param {any} ctx
517
+ * @returns {string}
535
518
  */
536
- removeGlobal(name) {
537
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
538
- const len0 = WASM_VECTOR_LEN;
539
- wasm.environment_removeGlobal(this.__wbg_ptr, ptr0, len0);
519
+ renderStr(source, ctx) {
520
+ let deferred3_0;
521
+ let deferred3_1;
522
+ try {
523
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
524
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
525
+ const len0 = WASM_VECTOR_LEN;
526
+ wasm.environment_renderStr(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(ctx));
527
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
528
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
529
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
530
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
531
+ var ptr2 = r0;
532
+ var len2 = r1;
533
+ if (r3) {
534
+ ptr2 = 0; len2 = 0;
535
+ throw takeObject(r2);
536
+ }
537
+ deferred3_0 = ptr2;
538
+ deferred3_1 = len2;
539
+ return getStringFromWasm0(ptr2, len2);
540
+ } finally {
541
+ wasm.__wbindgen_add_to_stack_pointer(16);
542
+ wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
543
+ }
544
+ }
545
+ /**
546
+ * Registers a synchronous template loader callback.
547
+ *
548
+ * The provided function is called with a template name and must return a
549
+ * string with the template source or `null`/`undefined` if the template
550
+ * does not exist. Errors thrown are propagated as MiniJinja errors.
551
+ * @param {Function} func
552
+ */
553
+ setLoader(func) {
554
+ wasm.environment_setLoader(this.__wbg_ptr, addHeapObject(func));
555
+ }
556
+ /**
557
+ * @param {boolean} yes
558
+ */
559
+ set debug(yes) {
560
+ wasm.environment_set_debug(this.__wbg_ptr, yes);
540
561
  }
541
562
  }
542
563
 
@@ -563,6 +584,16 @@ export function __wbg_call_672a4d21634d4a24() { return handleError(function (arg
563
584
  return addHeapObject(ret);
564
585
  }, arguments) };
565
586
 
587
+ export function __wbg_call_7cccdd69e0791ae2() { return handleError(function (arg0, arg1, arg2) {
588
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
589
+ return addHeapObject(ret);
590
+ }, arguments) };
591
+
592
+ export function __wbg_call_833bed5770ea2041() { return handleError(function (arg0, arg1, arg2, arg3) {
593
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
594
+ return addHeapObject(ret);
595
+ }, arguments) };
596
+
566
597
  export function __wbg_done_769e5ede4b31c67b(arg0) {
567
598
  const ret = getObject(arg0).done;
568
599
  return ret;
@@ -799,6 +830,11 @@ export function __wbindgen_is_function(arg0) {
799
830
  return ret;
800
831
  };
801
832
 
833
+ export function __wbindgen_is_null(arg0) {
834
+ const ret = getObject(arg0) === null;
835
+ return ret;
836
+ };
837
+
802
838
  export function __wbindgen_is_object(arg0) {
803
839
  const val = getObject(arg0);
804
840
  const ret = typeof(val) === 'object' && val !== null;
@@ -810,6 +846,11 @@ export function __wbindgen_is_string(arg0) {
810
846
  return ret;
811
847
  };
812
848
 
849
+ export function __wbindgen_is_undefined(arg0) {
850
+ const ret = getObject(arg0) === undefined;
851
+ return ret;
852
+ };
853
+
813
854
  export function __wbindgen_jsval_eq(arg0, arg1) {
814
855
  const ret = getObject(arg0) === getObject(arg1);
815
856
  return ret;
Binary file