I have a Jade template, and I want to pass a PHP variable $str into this template and show it. So in the template I put
{{$str}}
and then it got rendered like:
<title><?php echo $str ?></title>
I want the $str to be shown directly. But it's not mentioned in the node.php page.
Search online, there's some method like
eval("?>".$rendered."<?php");
and I believe this is a dirty solution because if my template has something like "?>" then everything would be wrong.
Is there a proper way of doing this thing?
Compile the template, store it in a .php file. Recompiling a file everytime you need it is a bad idea :).
I'd recommend using a md5file (or just md5 the file's content) to know if a file changed or not, and recompiling it on-the-fly.
and then just include it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With