Implementing a JS templating engine with current PHP project

Posted by SeanWM on Programmers See other posts from Programmers or by SeanWM
Published on 2013-11-01T13:01:40Z Indexed on 2013/11/01 16:20 UTC
Read the original article Hit count: 255

Filed under:
|

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?

© Programmers or respective owner

Related posts about templates

Related posts about js