How to use Handlebars.js and Smarty both?

smarty with javascript
how to use smarty in php
how to use php code in smarty
smarty rdelim
tpl smarty
smarty includes
smarty _server
smarty documentation

I am using Smarty for server-side templating and I want to use Handlebars.js for client-side templating but Smarty couse error because Handlebars use curly brackets same as Smarty. I can write Handlebars template in literal tags of Smarty but I cant use Smarty in Handlebars template this time.

For example: I write a smarty block function for cleanurl. I dont want to write a cleanurl function for javascript.So I want to use Smarty and Handlebars.js both.

<div class="model-item" id="model-{{id}}">
    <a href="{$mainurl}{cu}?com=model&act=view&id={{id}}{/cu}"> {{name}} </a>
</div>

You can also use literal tags...much better than escaping each curly brace.

{literal}
<script id="entry-template" type="text/x-handlebars-template">
  {{any_var}}
</script>
{/literal}

How to use Handlebars.js and Smarty both? - smarty - html, I am using Smarty for server-side templating and I want to use Handlebars.js for client-side templating but Smarty couse error because Handlebars use curly  The most important use of Handlebars, and any templating engine, is to keep your HTML pages simple and clean and decoupled from the logic-based JavaScript files, and Handlebars serves this purpose well. Indeed, Dust.js is also a logic-less templating engine and a worthy alternative to Handlebars.js.

http://www.smarty.net/docs/en/language.escaping.tpl

this section of the documentation discussing escaping. I think the "{ldelim},{rdelim}" may be what you are looking for...although it makes the code a bit less readable...

Handlebars.js vs Smarty, Smarty - Template engine for PHP. Handlebars.js and Mustache are both logicless templating languages that keep the What are the cons of using Smarty? Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be. Mustache It can be used for HTML, config files, source code - anything.

I know this is an old question, but this is now a supported smarty feature. (I stumbled across your question when I was looking for the same, so I wanted to answer it incase anyone else has the same issue)

if you add this:

$smarty->setLiterals(array('{{{','}}}','{{','}}'));

Smarty will now ignore all double and triple delims for mustache and handlebars. Note: Before enabling one must check their existing smarty templates for any legit smarty use of {{ or {{{ and rework their code as after setting, these are now literals and they will not longer function as smarty statements.

https://github.com/smarty-php/smarty/issues/508#issuecomment-437640751

this is as of version 3.1.32

{literal}, This is typically used around Javascript or stylesheet blocks where {curly braces} would If you need template tags embedded in a {literal} block, consider using  1 How to use Handlebars.js and Smarty both? Jun 6 '12. 1 some problems with kohana unittest (cli and web access) Jul 14 '12.

Handlebars vs. Smarty comparison, Smarty Template Engine – Spot the differences due to the helpful visualizations at a glance Website, handlebarsjs. Free for commercial use, Yes, Yes. Handlebars.js is an extension to the Mustache templating language created by Chris Wanstrath. Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.

Playing with Templating Libraries, And Smarty is for PHP. Mustache mainly accepts JavaScript objects as its data source and an html string for the template. You can just use jQuery or plain JavaScript to append the html contained by For the template were going to make use of a table to display both their names and nen ability:  Handlebars is a superset of the Mustache template engine. A template engine helps you separate your HTML from dynamic content created by languages such as JavaScript.

About handlebarsjs's ideology. Is it me or is it bad? : javascript, Let me preface this by saying I don't use Handlebars; I use Mustache Instead you format your Model with your View and pass both the template and the object As I recall, this was exactly the pitfall of the Smarty templates I've worked with. rbawaskar. Software Developer. 24. answers. 4. questions ~234k. people reached. 6 How to use Handlebars.js and Smarty both? Aug 1 '12. 6 svn: generic failure Jan

Comments
  • literal tags are good but when I use smarty and mustache vars both, code doing very complex and confusing. I decided to use underscore micro template and I am glad :)
  • I can use {ldelim} and {rdelim} but I must write the the all of the handlebars's brackets as {ldelim},{rdelim}.I think this may cause confusing also I think this delay development process.I cant change delimeters of Smarty because I using it in most places.I did not use handlebars anywhere.I can change delimeters of handlebars.Is this a good idea ? and this is possible?
  • perhaps write a custom function to output the brackets... (in Smarty)
  • I found set delimeter tags at mustache documentation.This exactly what am I looking.On handebars's site "Mustache templates are compatible with Handlebars, so you can take a Mustache template, import it into Handlebars, and start taking advantage of the extra Handlebars features.".Is there the feature in Handlebars?