Answer the question
In order to leave comments, you need to log in
Is it possible to insert php code into the handlebars template engine??
I'm going to start making a website for a person tomorrow. For the control system, you need to use webasyst (shop-script). I myself am more friends with the front, but in pxp + - se. And then such a strange idea came to me after the holidays. I read a little to the doc. The input file is essentially index.html to which other pages are connected via php. Is it possible to deploy all this as a spa application? (at least only the front without the admin panel) like this:
Connect webpack
Set up the index.htm input file (you get the input file of the theme being developed)
Set up the index.js input file (well, as usual, modules will be connected to it and it will be built in bundle js)
ps and I think js with a default theme to connect to it
All additional pages will be rewritten using the handlebars templating engine.
And here, so as not to lose the cms structure. I would like to do this (if possible):
Have a header.hbs template
<div id="header">
<?php echo '<h1>Привет, мир!</h1>'; ?>
</div>
import headerTemplate from {тут путь до header.hbs}
const Header = () => document.getElementById('app').innerHTML = headerTemplate()
import Header from {тут путь до header.js}
//render header
Header()
Answer the question
In order to leave comments, you need to log in
Handlebars template is processed at compile-time
At run-time there will be just a js function that takes a context object as input and returns a string.
Therefore, no php in the template will be executed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question