From b981d8f7c17440da0c4f85da25f88a4919e11013 Mon Sep 17 00:00:00 2001 From: MattMo <matt@montoyatech.com> Date: Tue, 21 Jun 2022 22:24:26 -0700 Subject: [PATCH] InnerText now supports functions. --- ignite-template.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ignite-template.js b/ignite-template.js index ecc51e7..f65dd2b 100644 --- a/ignite-template.js +++ b/ignite-template.js @@ -433,7 +433,7 @@ class IgniteTemplate { /** * Sets the inner text of the element to be constructed by this template. - * @param {String|IgniteProperty|IgniteProperty[]} value text to be set for this element. If a property is passed the text will auto update. + * @param {String|IgniteProperty|IgniteProperty[]|Function} value text to be set for this element. If a property is passed the text will auto update. * @param {Function} converter Optional function that can be used to convert the value if needed. * @returns This ignite template. */ @@ -468,8 +468,10 @@ class IgniteTemplate { }); this._elementInnerText = converter(...value.getPropertyValues()); + } else if (value instanceof Function) { + this._elementInnerText = converter ? converter(value()) : value(); } else { - this._elementInnerText = (converter != null ? converter(value) : value); + this._elementInnerText = converter ? converter(value) : value; } IgniteRenderingContext.pop();