-
Notifications
You must be signed in to change notification settings - Fork 0
/
Public.php
42 lines (34 loc) · 1.36 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
<?php
// Public functions
use ComponentLibrary\Init as ComponentLibraryInit;
if (!function_exists('algolia_search_page_render_blade_view')) {
function algolia_search_page_render_blade_view($view, $data = [], $compress = true)
{
$markup = "";
$viewPath = ALGOLIAINDEXJSSEARCHPAGE_VIEW_PATH;
$data = array_merge( $data, array('errorMessage' => false) );
$componentLibrary = new ComponentLibraryInit([]);
$bladeEngine = $componentLibrary->getEngine();
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;
}
}