请问Template filter该怎么用?

1 view
Skip to first unread message

ne.manman

unread,
Aug 15, 2006, 10:10:54 PM8/15/06
to django-cn
我在http://127.0.0.1:8000/admin/doc/filters/
里看到了许多Template filter函数, 里面有
add

Adds the arg to the value

addslashes

Adds slashes - useful for passing strings to JavaScript, for example.

.......等函数, 请问这些该怎么用?在哪里使用?

达人们可否详细的帮我解释下,谢谢

limodou

unread,
Aug 15, 2006, 10:51:45 PM8/15/06
to djan...@googlegroups.com
On 8/16/06, ne.manman <ne.m...@gmail.com> wrote:
> 我在http://127.0.0.1:8000/admin/doc/filters/
> 里看到了许多Template filter函数, 里面有
> add
>
> Adds the arg to the value
>
> addslashes
>
> Adds slashes - useful for passing strings to JavaScript, for example.
>
去看template文档。django的docs目录或它的网站上有,关于filter的用法。

--
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

ne.manman

unread,
Aug 15, 2006, 10:56:43 PM8/15/06
to django-cn
看的懂就不用麻烦您了

HackGou

unread,
Aug 22, 2006, 5:20:12 AM8/22/06
to django-cn
不知道manman有没有使用过其他的模版系统,比如php中的御用smarty。
django中的filter就相当于smarty的变量修改器。
比如你给个会自动对变量进行一些修改,调整。
比如那个addslashes常常用在javascript中,对"和'加斜线进行转义。其他的filter也差不多,
不同的filter功能不一样而已
Reply all
Reply to author
Forward
0 new messages