Implementing a JS templating engine with current PHP project
- by SeanWM
I'm currently working on a PHP project and quickly realizing how useful a templating engine would help me. I have a few tables whose table rows are looped out via a PHP loop. Is it possible to use just a JS templating engine (like Handlebarsjs) to also work with these tables? For example:
$arr = array('red', 'green', 'blue');
echo '<table>';
foreach($arr as $value) {
echo '<tr><td>' . $value . '</td></tr>';
}
echo '</table>';
Now I want to add a column via an ajax call using a JS templating engine. Is this possible? Or do I have to use a templating engine for both server side and client side?