diff --git a/CHANGELOG.md b/CHANGELOG.md index fa5d12e..3736d89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Use shorter compiled function body ids when not on development environment * Add basic `Optional` value-wrapper class support * Make sure variables are always cast to a `Variables` instance +* Add `Variables#get(key)` & `Variables#setFromTemplate(key, value)` method ## 2.3.19 (2024-04-13) diff --git a/lib/core/variables.js b/lib/core/variables.js index 682973a..90e414d 100644 --- a/lib/core/variables.js +++ b/lib/core/variables.js @@ -60,6 +60,28 @@ Variables.setProperty(function length() { return Object.keys(this).length; }); +/** + * Get a specific variable + * + * @author Jelle De Loecker + * @since 2.4.0 + * @version 2.4.0 + */ +Variables.setMethod(function get(key) { + return this[key]; +}); + +/** + * Set a specific variable from a template + * + * @author Jelle De Loecker + * @since 2.4.0 + * @version 2.4.0 + */ +Variables.setMethod(function setFromTemplate(key, value) { + return this[key] = value; +}); + /** * Get this instance's own key-values * (Skipping symbols)