How to use Handlebars.js and Smarty how?

I am using Smarty for server-side patterns, and I want to use Handlebars.js for client-side patterns, but with a Smarty couse error, because Handlebars use curly braces like Smarty. I can write the Handlebars template in Smarty literal tags, but this time I cannot use Smarty in the Handlebars template.

For example: I am writing a smarty block function for cleanurl. I do not want to write a cleanurl function for javascript. Therefore, I want to use Smarty and Handlebars.js.

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

You can also use literal tags ... much better than avoiding every curly brace.

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

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

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

+1
source

Source: https://habr.com/ru/post/1416356/


All Articles