There is a template-blank:

<script id="short-url" type="text/x-handlebars-template"> {% raw %} <div class="short-url"> <div class="url" data-placement="top" data-toggle="tooltip" data-original-title="{{ url }}" data-url="{{ url }}"> {{ url }} </div> <div class="icons"> <a href="{{ url }}" target="_blank" data-placement="top" data-toggle="tooltip" data-original-title="Go to the link"> <i class="im-link"></i> </a> <a class="hlink-clipboard" data-clipboard-text="{{ url }}" data-placement="top" data-toggle="clipboard" data-original-title="Copy the link"> <i class="im-copy"></i> </a> <a href="{{ single_page_url }}" target="_blank" data-placement="top" data-toggle="tooltip" data-original-title="Complete report for the page"> <i class="im-stats"></i> </a> <a href="{{ report_in_url }}" target="_blank" data-placement="top" data-toggle="tooltip" data-original-title="The Inbound Links Report URL"> <i class="im-arrow-down-left2"></i> </a> <a href="{{ report_out_url }}" target="_blank" data-placement="top" data-toggle="tooltip" data-original-title="The Outbound Links Report URL"> <i class="im-arrow-up-right3"></i> </a> </div> </div> {% endraw %} 

Everything is great in this workpiece, but you still need to translate sentences through Translation (they are now hard-coded) ... but in this case Twig begins to conflict with Handlebars. Let me clarify my idea: I want to draw static elements right away (when rendering the page), and to draw the dynamic parts later with JavaScript when iterating through the JSON array.

For example:

 <a href="{{ url }}" target="_blank" data-placement="top" data-toggle="tooltip" data-original-title="{{- table.go_to_link|trans -}}"> <i class="im-link"></i> </a> 

When rendering the page, data-original-title="{{- table.go_to_link|trans -}}"> should be replaced with the necessary offer.

Is it possible to do this? How?

    1 answer 1

    1. This question was solved by this link , but angular was applied there. To be brief, "{{" were replaced by "{[{", maybe you can do the same in your js framework?
    2. Also, you can remove {% raw%} and use the trick to draw templates for js: <a href="{{ '{{url}}' }}" , then everything will remain native in twig and in handlebars
    • Thank you very much. The second solution worked perfectly for me. The first is also good, even better than the first, but I find it inconvenient to implement it at the current moment in the project. - Mikhail Shchedrakov
    • @ Mikhail Shchedrakov was glad to help - AmsTaFFix