Comparing version 3.5.0 to 3.5.1
@@ -169,3 +169,3 @@ /** | ||
*/ | ||
use(pluginFn: (edge: this) => void): this; | ||
use<T extends any>(pluginFn: (edge: this, firstRun: boolean, options: T) => void, options?: T): this; | ||
/** | ||
@@ -172,0 +172,0 @@ * Register a custom tag |
@@ -10,2 +10,3 @@ import { ClaimTagFn } from 'edge-parser'; | ||
private options; | ||
private executedPlugins; | ||
/** | ||
@@ -56,3 +57,3 @@ * Options passed to the compiler instance | ||
*/ | ||
use(pluginFn: (edge: this) => void): this; | ||
use<T extends any>(pluginFn: (edge: this, firstRun: boolean, options: T) => void, options?: T): this; | ||
/** | ||
@@ -59,0 +60,0 @@ * Mount named directory to use views. Later you can reference |
@@ -43,2 +43,3 @@ "use strict"; | ||
this.options = options; | ||
this.executedPlugins = false; | ||
/** | ||
@@ -84,7 +85,15 @@ * Options passed to the compiler instance | ||
executePlugins() { | ||
if (!this.plugins.length) { | ||
return; | ||
if (this.executedPlugins) { | ||
this.plugins.forEach(({ fn, options }) => { | ||
if (options && options.recurring) { | ||
fn(this, false, options); | ||
} | ||
}); | ||
} | ||
this.plugins.forEach((pluginFn) => pluginFn(this)); | ||
this.plugins = []; | ||
else { | ||
this.executedPlugins = true; | ||
this.plugins.forEach(({ fn, options }) => { | ||
fn(this, true, options); | ||
}); | ||
} | ||
} | ||
@@ -95,4 +104,7 @@ /** | ||
*/ | ||
use(pluginFn) { | ||
this.plugins.push(pluginFn); | ||
use(pluginFn, options) { | ||
this.plugins.push({ | ||
fn: pluginFn, | ||
options, | ||
}); | ||
return this; | ||
@@ -99,0 +111,0 @@ } |
{ | ||
"name": "edge.js", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "Template engine", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125721
3536