From 57ae4ca26227cf0269c80704800c0753c48eca17 Mon Sep 17 00:00:00 2001 From: petersirka Date: Tue, 3 Sep 2024 21:09:22 +0200 Subject: [PATCH] Added `@{url}` and `@{hostname([url])}` commands. --- changelog.txt | 2 ++ viewengine.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9c1ec9a..e5bcd29 100644 --- a/changelog.txt +++ b/changelog.txt @@ -20,6 +20,8 @@ - added a new argument `size {Number}` to the `WebSocket.on('message', function(client, msg, [size]))` event - fixed `@{href()}` command in the ViewEngine - improved config & resource parser by adding support for `=` between key and value and for `#` as a comment +- removed `@{url()}` method and added `@{url}` property +- added `@{hostname([url])}` ======================== 0.0.5 diff --git a/viewengine.js b/viewengine.js index 85cc41e..2b68bc0 100644 --- a/viewengine.js +++ b/viewengine.js @@ -591,6 +591,7 @@ function View(controller) { self.language = controller?.language || ''; self.repository = { layout: 'layout' }; self.islayout = false; + self.url = controller?.url || ''; } View.prototype.ota = function(obj) { @@ -857,9 +858,9 @@ View.prototype.section = function(name, value, replace) { return self; }; -View.prototype.url = function(hostname = false) { +View.prototype.hostname = function(url) { var self = this; - return hostname ? (self.controller ? self.controller.hostname(self.controller.url) : '') : (self.controller ? self.controller.url : ''); + return self.controller ? self.controller.hostname(url == null ? self.controller.url : url) : (url || ''); }; View.prototype.set = function() {