Skip to content

Commit 52ff455

Browse files
authored
add JAVASCRIPT_DATA
1 parent f71921e commit 52ff455

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

routes/helpers/base.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Application helpers
55
*/
66

7+
use Monster\App\Models\Env;
8+
79
// Load Thems
810
function view($path, $data = [])
911
{
@@ -15,5 +17,12 @@ function view($path, $data = [])
1517
// include views folder path
1618
$viewPath = 'views/' . $path . '.php';
1719

20+
$env = new Env('.env');
21+
$javascript = $env->get("JAVASCRIPT_DATA");
22+
23+
if ($javascript == "true") {
24+
echo "<script>let monster = JSON.parse('" . json_encode($data) . "')</script>";
25+
}
26+
1827
include_once $viewPath;
19-
}
28+
}

0 commit comments

Comments
 (0)