generated from helsingborg-stad/modularity-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublic.php
executable file
·39 lines (32 loc) · 1.28 KB
/
Public.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
use ComponentLibrary\Init;
if (!function_exists('modularity_products_render_blade_view')) {
function modularity_products_render_blade_view($view, $data = [], $compress = true)
{
$componentLibrary = new Init([]);
$bladeEngine = $componentLibrary->getEngine();
$viewPath = MODULARITY_PRODUCTS_MODULE_VIEW_PATH;
$data = array_merge($data, array('errorMessage' => false));
try {
$markup = $bladeEngine->makeView($view, $data, [], $viewPath)->render();
} catch (\Throwable $e) {
$markup .= '<pre style="border: 3px solid #f00; padding: 10px;">';
$markup .= '<strong>' . $e->getMessage() . '</strong>';
$markup .= '<hr style="background: #000; outline: none; border:none; display: block; height: 1px;"/>';
$markup .= $e->getTraceAsString();
$markup .= '</pre>';
}
if ($compress == true) {
$replacements = array(
["~<!--(.*?)-->~s", ""],
["/\r|\n/", ""],
["!\s+!", " "]
);
foreach ($replacements as $replacement) {
$markup = preg_replace($replacement[0], $replacement[1], $markup);
}
return $markup;
}
return $markup;
}
}