So I have a JavaScript that returns an output variable looking like this:
<script id="cat-template" type="text/x-handlebars-template">
<div class="chart">
<h2>{{Name}}</h2>
<h3 style="color:#ff0099;font-size:250%"> {{Status}}</h3>
</script>
What I would like to do is have it as a part of this php snippet:
<?php
$status = {{Status}};
if ($status = "1") {
echo "Good day, bud!";}
else {
echo "Good night, pal!";}
?>
the {{Status}}
doesn't work in the php snippet.
Any thoughts?
You Must On Parse HTML AND JavaScript AS PHP String
Simple Example :
index.html
<html>
<head>
....
....
....
</head>
<body>
<p>Your Username Is :{{username}}</p>
</body>
</html>
PHP Code :
<?php
$username ="Test";
$content=file_get_contents("/theme/index.html");
$content=str_replace("{{username}}",$username,$content);
echo $content;
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.