diff --git a/src/Edge/index.js b/src/Edge/index.js index c9f2242..a23cdcd 100644 --- a/src/Edge/index.js +++ b/src/Edge/index.js @@ -52,7 +52,7 @@ class Edge { * * @method _getTemplate * - * @return {Object} + * @return {Template} * * @private */ @@ -62,6 +62,17 @@ class Edge { }, this._globals, this._loader) } + /** + * Returns a fresh instance of template + * + * @method new + * + * @returns {Template} + */ + new () { + return this._getTemplate() + } + /** * Registers a new tag. A tag must have following * attributes. @@ -164,42 +175,42 @@ class Edge { * docblock defined in template renderer */ renderString (...args) { - return this._getTemplate().renderString(...args) + return this.new().renderString(...args) } /** * docblock defined in template renderer */ compileString (...args) { - return this._getTemplate().compileString(...args) + return this.new().compileString(...args) } /** * docblock defined in template renderer */ render (view, ...args) { - return this._getTemplate().render(view, ...args) + return this.new().render(view, ...args) } /** * docblock defined in template renderer */ compile (view, ...args) { - return this._getTemplate().compile(view, ...args) + return this.new().compile(view, ...args) } /** * docblock defined in template renderer */ presenter (...args) { - return this._getTemplate().presenter(...args) + return this.new().presenter(...args) } /** * docblock defined in template renderer */ share (...args) { - return this._getTemplate().share(...args) + return this.new().share(...args) } } diff --git a/test/unit/edge.spec.js b/test/unit/edge.spec.js index 0b6e80c..abe0974 100644 --- a/test/unit/edge.spec.js +++ b/test/unit/edge.spec.js @@ -267,4 +267,11 @@ test.group('Edge', (group) => { const statement = `{{ foo }} {{ bar }}` assert.equal(sharedInstance.renderString(statement).trim(), 'bar baz') }) + + test('edge.new return isolated instance', (assert) => { + const edge = new Edge() + const templ = edge.new() + const templ2 = edge.new() + assert.isFalse(templ === templ2) + }) })