-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40e6483
commit 249c81b
Showing
4 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
test | ||
Experimental | ||
vendor | ||
composer.lock | ||
composer.lock | ||
# Alchemy | ||
.alchemy | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
app: | ||
- src | ||
|
||
tests: | ||
engine: pest | ||
parallel: true | ||
paths: | ||
- tests | ||
files: | ||
- '*.test.php' | ||
coverage: | ||
local: false | ||
actions: true | ||
|
||
lint: | ||
preset: PSR12 | ||
ignore_tests: true | ||
rules: | ||
no_unused_imports: true | ||
not_operator_with_successor_space: false | ||
single_quote: true | ||
|
||
actions: | ||
run: | ||
- lint | ||
os: | ||
- ubuntu-latest | ||
php: | ||
extensions: json, zip, dom, curl, libxml, mbstring | ||
versions: | ||
- '8.3' | ||
events: | ||
- push | ||
- pull_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,20 @@ | |
* Bare UI | ||
* ------------ | ||
* Leaf templating language focused on speed, speed and more speed. | ||
* | ||
* | ||
* @since v2.4.4 | ||
* @author Michael Darko <[email protected]> | ||
*/ | ||
class BareUI | ||
{ | ||
private static $config = [ | ||
"path" => null, | ||
"params" => [], | ||
'path' => null, | ||
'params' => [], | ||
]; | ||
|
||
/** | ||
* Configure bare UI | ||
* | ||
* | ||
* @param array|string $item The item(s) to configure | ||
* @param mixed $value Value of config. Ignored if $item is array. | ||
*/ | ||
|
@@ -34,40 +34,40 @@ public static function config($item, $value = null) | |
|
||
/** | ||
* Render a bare UI | ||
* | ||
* | ||
* @param string $view The view to render | ||
* @param array $data The params to pass into UI | ||
*/ | ||
public static function render(string $view, array $data = []) | ||
{ | ||
$view = static::getView($view); | ||
$path = "./"; | ||
$path = './'; | ||
|
||
if (class_exists("\Leaf\Config")) { | ||
$path = Config::get("views.path"); | ||
$path = Config::get('views.path'); | ||
} | ||
|
||
if (!file_exists($file = (static::$config["path"] ?? $path) . "/$view")) { | ||
if (!file_exists($file = (static::$config['path'] ?? $path) . "/$view")) { | ||
trigger_error("The file $view could not be found."); | ||
} | ||
|
||
extract(array_merge($data, ['template' => self::class], static::$config["params"])); | ||
extract(array_merge($data, ['template' => self::class], static::$config['params'])); | ||
|
||
ob_start(); | ||
|
||
try { | ||
include($file); | ||
include $file; | ||
} catch (\Throwable $th) { | ||
trigger_error($th); | ||
} | ||
|
||
return (ob_get_clean()); | ||
return ob_get_clean(); | ||
} | ||
|
||
private static function getView($view) | ||
{ | ||
if (!strpos($view, ".view.php")) { | ||
$view .= ".view.php"; | ||
if (!strpos($view, '.view.php')) { | ||
$view .= '.view.php'; | ||
} | ||
|
||
return $view; | ||
|