简体   繁体   中英

Display php code in handlebar template

How do I display php code in handlebar template ?

example -

<script type="text/x-handlebars">
        <span class="label label-default"> <?php echo "I am inside handlebar template" ?>  </span> 
    </script>

This does not produce any output ?

Are there any other alternatives ?

MORE EXPLANATION---

Actually I am embedding the handlebars template inside an index.php by using the script type="text/x-handlebars" . Now based on the some scenario I need to call a php library inside the handlebars template

PHP should render a regular text (HTML) file. So there's no reason this wouldn't work perfectly fine.

Also what your doing only barely makes sense. Handlebars is meant to display variables. I'd have the server render the data to a variable, then display that with a variable name -- unless I suppose your gradually migrating PHP to client-side or something. Serving the same page with an external reference to the variable data set (an API) is also good for caching. Just my 2 cents, don't know your situation!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM