Index

JSVariable

MMO\core\helpers · 1 symbol · generated 30 Sep 2026

class

JSVariable

JSVariable.php:14

Represents a name = <json>; JavaScript variable assignment, to embed server-side data into an HTML document's inline <script> (used by HtmlDocument). Pretty-printed in MODE_DEV, compact otherwise.

class MMO\core\helpers\JSVariable implements MMO\core\interfaces\iRenderable
Namespace
MMO\core\helpers
Implements
iRenderable
$v = new JSVariable('window.config', ['a' => 1, 'b' => 'x']); (string)$v; // "window.config = {\n \"a\": 1,\n \"b\": \"x\"\n};" in MODE_DEV

Properties2

value

mixed $value
Type
mixed

Methods3

__construct($name, $value)

JSVariable.php:23
function __construct(string $name, mixed $value)
$namestringthe JS variable/path to assign to (e.g. 'window.config')
$valuemixedany JSON-encodable value