I have a case to render a template from a SQL database to jinja2.
In table shop, I have a string value like that in column shop.sms_body of table shop!
{{ location.name }} kính chào quý khách!
Đã {{ order.days }} ngày kể từ đơn hàng {{ order.order_name }}, chúng tôi rất mong ý kiến của quý khách để ngày càng phục vụ khách hàng tốt hơn.
Mong quý khách liên hệ chúng tôi qua số phone {{ location.phone }}, hoặc ghé thăm website {{ location.address1 }}!
Chúng tôi chân thành cám ơn
In jinja2, my code is, i render shop, and get sms body {{ shop.sms_body|safe }}
<a class="text-left"
href="sms:{{ order.canonicalForm }}&body={{ shop.sms_body|safe }}"><img
src="/static/img/sms_icon.png" width="30px"></a>
When I click "sms message" this is what I want: {{ location.name }}..
etc have to render phone of location, but it still like image
Does anyone have a solution to this case?
Thanks in advance
Thanks! I find out solution In flask
sms_body = shop.sms_body
print(sms_body)
sms_body = Template(sms_body)
list_sms_body = [sms_body.render(shop=shop, location=location, order=order) for order in orders]
if orders == []:
return redirect(url_for("remind.update_remind_customer", date=date))
else:
return render_template('/remind_customer.html', orders=orders, shop=shop, location=location, date=date,
next_date=next_date, pre_date=pre_date, list_sms_body=list_sms_body)
after that in html
{% if shop.use_remind_customers == True %}
{% for index in range(orders|length) %}
{% set order = orders[index] %}
{% set sms_body = list_sms_body[index] %}
<a class="text-left"
href="sms:{{ order.canonicalForm }}&body={{ sms_body|safe }}"><img
src="/static/img/sms_icon.png" width="30px"></a>
{% endfor %}
{% endif %}
Have you looked atescaping section of docs? You can use the raw
block for this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.