Attribute extension now allows functions to be used for the value for more dynamic code.
This commit is contained in:
		| @@ -139,7 +139,7 @@ class IgniteTemplate { | |||||||
|     /** |     /** | ||||||
|      * Adds a html element attribute to this template to be added once this template is constructed. |      * Adds a html element attribute to this template to be added once this template is constructed. | ||||||
|      * @param {String} name The name of the attribute to add |      * @param {String} name The name of the attribute to add | ||||||
|      * @param {String|IgniteProperty} value The value of the attribute to set, can be anything. If Property is passed it will auto update. |      * @param {String|IgniteProperty|Function} value The value of the attribute to set, can be anything. If Property is passed it will auto update. | ||||||
|      * @param {Function} converter Optional function that can convert the value if needed. |      * @param {Function} converter Optional function that can convert the value if needed. | ||||||
|      * @returns {IgniteTemplate} This ignite template so function calls can be chained. |      * @returns {IgniteTemplate} This ignite template so function calls can be chained. | ||||||
|      */ |      */ | ||||||
| @@ -173,6 +173,8 @@ class IgniteTemplate { | |||||||
|             }); |             }); | ||||||
|  |  | ||||||
|             this._attributes[name] = converter(...value.getPropertyValues()); |             this._attributes[name] = converter(...value.getPropertyValues()); | ||||||
|  |         } else if (value instanceof Function) { | ||||||
|  |             this._attributes[name] = converter ? converter(value()) : value(); | ||||||
|         } else { |         } else { | ||||||
|             this._attributes[name] = converter ? converter(value) : value; |             this._attributes[name] = converter ? converter(value) : value; | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user