标签:htm ret user html 工厂 go import sim else safe
1,变量{{}}
2,标签{%%}
3,导入模板
{% extends ‘master.html‘ %}
{% block css %}
<style>
form{
clear: both;
}
</style>
{% endblock %}
{% load staticfiles %} <!--导入静态文件-->
{%static ‘uri‘%}
{% load temp %}
{% if a|ret3:d > 10 %}
<p>错误</p>
{% else %}
<p>{{ a|ret3:d }}</p>
{% endif %}
from django import template
from django.utils.safestring import mark_safe
register=template.Library() #调用template下的工厂函数
@register.simple_tag
def ret1(a,b,c):
return a+b+c
@register.filter
def ret2(a,b):
return a+b
@register.filter
def ret3(a,d):
for line in d:
a+=line
return a
@register.simple_tag
def ret4():
return mark_safe("<input type=text name=‘user‘>")
标签:htm ret user html 工厂 go import sim else safe
原文地址:http://www.cnblogs.com/tiantao36/p/7499885.html