Skip to content

Commit

Permalink
✨ Also define the shared constants as globals in Hawkejs templates
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Feb 20, 2024
1 parent 210fca5 commit ce76952
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
37 changes: 26 additions & 11 deletions lib/scripts/create_shared_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @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
*
Expand All @@ -37,7 +52,7 @@ DEFINE('DEFINE', DEFINE);
*
* @type {Informer}
*/
DEFINE('Blast', __Protoblast);
DEFINE_CLIENT('Blast', __Protoblast);

/**
* All classes will be collected here
Expand All @@ -48,7 +63,7 @@ DEFINE('Blast', __Protoblast);
*
* @type {Object}
*/
DEFINE('Classes', Blast.Classes);
DEFINE_CLIENT('Classes', Blast.Classes);

/**
* Available types
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -92,4 +107,4 @@ DEFINE('MutableFixedDecimal', Classes.Develry.MutableFixedDecimal);
* @since 1.4.0
* @version 1.4.0
*/
DEFINE('Trail', Classes.Develry.Trail);
DEFINE_CLIENT('Trail', Classes.Develry.Trail);
1 change: 0 additions & 1 deletion lib/scripts/preload_modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ alchemy.use('less', 'less');
*
* @link https://npmjs.org/package/hawkejs
*/
alchemy.use('hawkejs', 'hawkejs');
alchemy.hawkejs = Classes.Hawkejs.Hawkejs.getInstance();

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"keywords": [
"alchemy",
Expand Down

0 comments on commit ce76952

Please sign in to comment.