-
Notifications
You must be signed in to change notification settings - Fork 0
/
Public.php
37 lines (30 loc) · 1.1 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
<?php
// Public functions
use ComponentLibrary\Init as ComponentLibraryInit;
if (!function_exists('liked_posts_render_blade_view')) {
function liked_posts_render_blade_view($view, $data = [], $compress = true)
{
$markup = '';
$componentLibrary = new ComponentLibraryInit([]);
$bladeEngine = $componentLibrary->getEngine();
$viewPaths = [MODULARITYLIKEPOSTS_MODULE_VIEW_PATH, MODULARITYLIKEPOSTS_VIEW_PATH];
$data = array_merge($data, array('errorMessage' => false));
try {
$markup = $bladeEngine->makeView($view, $data, [], $viewPaths)->render();
} catch (\Throwable $e) {
$bladeEngine->errorHandler($e)->print();
}
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;
}
}