diff --git a/CHANGELOG.md b/CHANGELOG.md index 80f0c0ae..a44b1aae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.4.0-alpha.3 (WIP) + +* Also define the shared constants as globals in Hawkejs templates + ## 1.4.0-alpha.2 (2024-02-19) * Drop the correct already-existing index when trying to create a similar one diff --git a/lib/bootstrap.js b/lib/bootstrap.js index dfcb7dc5..b8488276 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -7,6 +7,11 @@ const libpath = require('path'); */ const Protoblast = require('protoblast')(true); +/** + * Require Hawkejs next + */ +require('hawkejs'); + /** * Define shared global constants and require methods */ diff --git a/lib/scripts/create_shared_constants.js b/lib/scripts/create_shared_constants.js index 5e5c0769..842203f9 100644 --- a/lib/scripts/create_shared_constants.js +++ b/lib/scripts/create_shared_constants.js @@ -17,6 +17,21 @@ function DEFINE(name, value) { Object.defineProperty(globalThis, name, {value: value}); } +/** + * Function to define global constants + * and have them inside Hawkejs views too + * + * @author Jelle De Loecker + * @since 1.4.0 + * @version 1.4.0 + * + * @type {Function} + */ +function DEFINE_CLIENT(name, value) { + DEFINE(name, value); + Classes.Hawkejs.setGlobal(name, value); +} + /** * Use DEFINE for itself * @@ -37,7 +52,7 @@ DEFINE('DEFINE', DEFINE); * * @type {Informer} */ -DEFINE('Blast', __Protoblast); +DEFINE_CLIENT('Blast', __Protoblast); /** * All classes will be collected here @@ -48,7 +63,7 @@ DEFINE('Blast', __Protoblast); * * @type {Object} */ -DEFINE('Classes', Blast.Classes); +DEFINE_CLIENT('Classes', Blast.Classes); /** * Available types @@ -59,7 +74,7 @@ DEFINE('Classes', Blast.Classes); * * @type {Object} */ -DEFINE('Types', Blast.Types); +DEFINE_CLIENT('Types', Blast.Types); /** * The new Local Date/Time classes @@ -68,9 +83,9 @@ DEFINE('Types', Blast.Types); * @since 1.3.20 * @version 1.3.20 */ -DEFINE('LocalDateTime', Classes.Develry.LocalDateTime); -DEFINE('LocalDate', Classes.Develry.LocalDate); -DEFINE('LocalTime', Classes.Develry.LocalTime); +DEFINE_CLIENT('LocalDateTime', Classes.Develry.LocalDateTime); +DEFINE_CLIENT('LocalDate', Classes.Develry.LocalDate); +DEFINE_CLIENT('LocalTime', Classes.Develry.LocalTime); /** * The new Decimal classes @@ -79,10 +94,10 @@ DEFINE('LocalTime', Classes.Develry.LocalTime); * @since 1.3.20 * @version 1.3.20 */ -DEFINE('Decimal', Classes.Develry.Decimal); -DEFINE('MutableDecimal', Classes.Develry.MutableDecimal); -DEFINE('FixedDecimal', Classes.Develry.FixedDecimal); -DEFINE('MutableFixedDecimal', Classes.Develry.MutableFixedDecimal); +DEFINE_CLIENT('Decimal', Classes.Develry.Decimal); +DEFINE_CLIENT('MutableDecimal', Classes.Develry.MutableDecimal); +DEFINE_CLIENT('FixedDecimal', Classes.Develry.FixedDecimal); +DEFINE_CLIENT('MutableFixedDecimal', Classes.Develry.MutableFixedDecimal); /** * The Trail class: @@ -92,4 +107,4 @@ DEFINE('MutableFixedDecimal', Classes.Develry.MutableFixedDecimal); * @since 1.4.0 * @version 1.4.0 */ -DEFINE('Trail', Classes.Develry.Trail); \ No newline at end of file +DEFINE_CLIENT('Trail', Classes.Develry.Trail); \ No newline at end of file diff --git a/lib/scripts/preload_modules.js b/lib/scripts/preload_modules.js index 5ffeb5e4..fbbf8903 100644 --- a/lib/scripts/preload_modules.js +++ b/lib/scripts/preload_modules.js @@ -49,7 +49,6 @@ alchemy.use('less', 'less'); * * @link https://npmjs.org/package/hawkejs */ -alchemy.use('hawkejs', 'hawkejs'); alchemy.hawkejs = Classes.Hawkejs.Hawkejs.getInstance(); /** diff --git a/package.json b/package.json index 72908a74..42376c16 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alchemymvc", "description": "MVC framework for Node.js", - "version": "1.4.0-alpha.2", + "version": "1.4.0-alpha.3", "author": "Jelle De Loecker ", "keywords": [ "alchemy",