-
Notifications
You must be signed in to change notification settings - Fork 121
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
a886138
commit 6fa51ba
Showing
15 changed files
with
577 additions
and
241 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
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,49 +1,49 @@ | ||
{ | ||
"name": "eftec/bladeone", | ||
"description": "The standalone version Blade Template Engine from Laravel in a single php file", | ||
"type": "library", | ||
"keywords": [ | ||
"blade", | ||
"template", | ||
"view", | ||
"php", | ||
"templating" | ||
], | ||
"homepage": "https://github.com/EFTEC/BladeOne", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Jorge Patricio Castro Castillo", | ||
"email": "jcastro@eftec.cl" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.2.5", | ||
"ext-json": "*" | ||
}, | ||
"suggest": { | ||
"ext-mbstring": "This extension is used if it's active", | ||
"eftec/bladeonehtml": "Extension to create forms" | ||
}, | ||
"archive": { | ||
"exclude": [ | ||
"/examples" | ||
] | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"eftec\\bladeone\\": "lib/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"eftec\\tests\\": "tests/" | ||
} | ||
}, | ||
"bin": [ | ||
"lib/bladeonecli" | ||
], | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.5.23" | ||
} | ||
} | ||
{ | ||
"name": "eftec/bladeone", | ||
"description": "The standalone version Blade Template Engine from Laravel in a single php file", | ||
"type": "library", | ||
"keywords": [ | ||
"blade", | ||
"template", | ||
"view", | ||
"php", | ||
"templating" | ||
], | ||
"homepage": "https://github.com/EFTEC/BladeOne", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Jorge Patricio Castro Castillo", | ||
"email": "jcastro@eftec.cl" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.2", | ||
"ext-json": "*" | ||
}, | ||
"suggest": { | ||
"ext-mbstring": "This extension is used if it's active", | ||
"eftec/bladeonehtml": "Extension to create forms" | ||
}, | ||
"archive": { | ||
"exclude": [ | ||
"/examples" | ||
] | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"eftec\\bladeone\\": "lib/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"eftec\\tests\\": "tests/" | ||
} | ||
}, | ||
"bin": [ | ||
"lib/bladeonecli" | ||
], | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.5.23" | ||
} | ||
} |
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,48 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2024 Jorge Patricio Castro Castillo MIT License. | ||
*/ | ||
include "../lib/BladeOne.php"; | ||
use eftec\bladeone\BladeOne; | ||
|
||
$views = __DIR__ . '/views'; | ||
$compiledFolder = __DIR__ . '/compiled'; | ||
$blade=new BladeOne($views, $compiledFolder, BladeOne::MODE_DEBUG); | ||
$blade->pipeEnable=true; | ||
|
||
|
||
$blade->clearMethods(); | ||
|
||
$blade->addMethod('runtime','table',static function($args) { | ||
// in this context, $this means the autoTest class and not the blade class. | ||
$args=array_merge(['alias'=>'alias'],$args); // you could use array merge to set a default value. | ||
BladeOne::$instance->addControlStackChild('runtimeTable',$args); // we store the current control in the stack. | ||
return '<ul>'; | ||
}); | ||
$blade->addMethod('runtime','endtable',static function($args) { | ||
BladeOne::$instance->closeControlStack(); | ||
return '</ul>'; | ||
}); | ||
$blade->addMethod('runtime','row',static function() { | ||
$parent=BladeOne::$instance->lastControlStack()['args']; // getting the values of the parent control using the stack | ||
$result=''; | ||
foreach($parent['values'] as $v) { | ||
$result.=BladeOne::$instance->runChild('auto.test2_control',[$parent['alias']=>$v]); | ||
} | ||
return $result; | ||
}); | ||
$blade->addMethod('runtime','row2',function() { | ||
$parent=BladeOne::$instance->lastControlStack()['args']; // getting the values of the parent control using the stack | ||
$result=''; | ||
foreach($parent['values'] as $v) { | ||
$result.="<li>$v</li>\n"; | ||
} | ||
return $result; | ||
}); | ||
|
||
|
||
try { | ||
echo $blade->run("auto.test2",['countries' => ["chile","argentina","peru"]]); | ||
} catch (Exception $e) { | ||
echo "error found ".$e->getMessage()."<br>".$e->getTraceAsString(); | ||
} |
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,32 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2024 Jorge Patricio Castro Castillo MIT License. | ||
*/ | ||
include "../lib/BladeOne.php"; | ||
use eftec\bladeone\BladeOne; | ||
|
||
$views = __DIR__ . '/views'; | ||
$compiledFolder = __DIR__ . '/compiled'; | ||
$blade=new BladeOne($views, $compiledFolder, BladeOne::MODE_DEBUG); | ||
$blade->pipeEnable=true; | ||
|
||
|
||
$blade->clearMethods(); | ||
|
||
|
||
$blade->addMethod('runtime','card',static function($args) { | ||
$result=''; | ||
$result.=BladeOne::$instance->runChild('auto.card',['value'=>$args[0]]); | ||
return $result; | ||
}); | ||
|
||
|
||
try { | ||
echo $blade->run("auto.test3",['items' => [ | ||
['title'=>"chile",'content'=>'lorem ipsum'], | ||
['title'=>"argentina",'content'=>'lorem ipsum'], | ||
['title'=>"peru",'content'=>'lorem ipsum'], | ||
]]); | ||
} catch (Exception $e) { | ||
echo "error found ".$e->getMessage()."<br>".$e->getTraceAsString(); | ||
} |
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,7 @@ | ||
<div class="card" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title">{{$value['title']}}</h5> | ||
<p class="card-text">{{$value['content']}}</p> | ||
<a href="#" class="btn btn-primary">Go somewhere</a> | ||
</div> | ||
</div> |
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,4 @@ | ||
it is test 1 | ||
@one(a1="hola" a2="mundo") | ||
|
||
two:@two(1,2,3) |
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,6 @@ | ||
@table(values=$countries alias="alias") | ||
row: | ||
@row() | ||
row2: | ||
@row2() | ||
@endtable |
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 @@ | ||
<li>{{$alias}}</li> |
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,29 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | ||
|
||
<title>Hello, world!</title> | ||
</head> | ||
<body> | ||
<h1>Hello, world!</h1> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
@foreach($items as $item) | ||
@card($item) | ||
@endforeach | ||
</div> | ||
</div> | ||
|
||
<!-- Optional JavaScript --> | ||
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | ||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.3/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.