-
Notifications
You must be signed in to change notification settings - Fork 0
/
Public.php
executable file
·46 lines (38 loc) · 1.38 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
40
41
42
43
44
45
46
<?php
use ComponentLibrary\Init as ComponentLibraryInit;
if (!function_exists('modularity_{{BPREPLACESLUG}}_render_blade_view')) {
function modularity_{{BPREPLACESLUG}}_render_blade_view($view, $data = [], $compress = true)
{
$init = new ComponentLibraryInit([
{{BPREPLACECAPSCONSTANT}}_MODULE_VIEW_PATH
]);
$bladeEngine = $init->getEngine();
try {
$markup = $bladeEngine->make(
$view,
array_merge(
$data,
array('errorMessage' => false)
)
)->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;
}
}