Open olanod opened 11 years ago
Actually, the way to use php vars is the fallowing :
<?php
require '../vendor/autoload.php';
use Jade\Jade;
$jade = new Jade();
$user = 'Admin';
eval(
'?>'.
$jade->render(
'h1 Hi #{$user}'
)
);
But trust me, i really hate the eval and the lack of scope.
it looks ugly but it does the job.
I'm more concerned about the security of using eval()
, is the data scaped when is dumped? in my(or anyone) use cases the input shouldn't be trusted.
For example I have a render function which receives an array that will be used as the scope in the template and the array could be anything like user submitted data:
function render($template,$scope=null) {
if ($scope !== null && is_array($scope)) {
extract($scope);
}
ob_start();
eval('?>' . $jade->render($template));
$content = ob_get_contents();
ob_clean();
return $content;
}
I didn't find a way to pass a context/scope to the template being rendered. Is it possible?