[Symfony3, twgig - template]
return x; - constantly returns a string like "<span>710</span>₽<div><span>319.5000</span>₽</div>" , and I need html, tags for generating content, how can I render them?
<script type="text/javascript"> function searchCertificateAction() { var template = "<div class='pr-one'>" + "<div class='img'>" + "<img title='${name}' src='${image}'>" + "</div>" + "<div class='pr-name'>" + "${name}" + "</div>" + "<div class='price sale-price'>"+ "${price_result}"+ "</div>" + "<div class='pay'><span>В корзину</span></div>" + "</div>"; var empty = "<p>No response...</p>"; $("#certificate_search_certificate input[type = 'submit']").on('click', function (e) { e.preventDefault(); $.ajax({ type: "POST", dataType: 'json', data: $('#certificate_search_certificate').serialize(), url: '{{ path("app.client.catalog", {"category_parent": 'all', "category_children": 'all'}) }}', success: function (data) { var dataParse = JSON.parse(data.certificate_response); var resultHtml = "#products"; $(resultHtml).empty(); if (dataParse.length !== 0) { for (var i = 0; i < dataParse.length; i++) { $.tmpl(template, { "id": dataParse[i].id, "name": dataParse[i].name, "price": dataParse[i].price, "image": dataParse[i].image, "total_price": dataParse[i].total_price, "price_result": function (total_price = dataParse[i].total_price, price = dataParse[i].price) { if (total_price === undefined) { var x = "<div><span>" + price + "</span>₽</div>"; return x; } else { var x = "<span>" + price + "</span>₽<div><span>" + total_price + "</span>₽</div>"; return x; } } }).appendTo(resultHtml); } } else { $.tmpl(empty, {}).appendTo(resultHtml); } } }); }); } searchCertificateAction(); </script>
"<span>710</span>₽<div><span>319.5000</span>₽</div>"is it not html or what? - teran>and<? :) what is the$.tmpl()function you have? - teranjquery templatesthen something like in the template you can write not${price_result}but{{html price_result}}, check if you can write a response. - teran{{ path("app.client.catalog", {"category_parent": 'all', "category_children": 'all'}) }}- Maxim Strutinskiy