Python论坛  - 讨论区

标题:[python-chinese] django模板里头的block如果嵌入到ifequal里头的话似乎不起作用?

2007年11月13日 星期二 12:31

huang jayven kassarar在gmail.com
星期二 十一月 13 12:31:51 HKT 2007

请教大家一个问题,如果将block嵌到ifequal里头的话,貌似是不起作用的,文档里有没有什么地方有说明这样的原因?

################## father.html ##################


{% ifequal a 0 %}
    {% block main %}
        father here
    {% endblock main %}
{% endifequal %}



################## child.html ###################
{% extends "father.html" %}

{% block main %}
    child here
{% endblock main %}

##############################################
>>> from django.template.loader import render_to_string
>>>
>>> print render_to_string('father.html', {'a': 0})




father here





>>> print render_to_string('child.html', {'a': 0})




father here





>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20071113/add63a47/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月13日 星期二 19:41

GTcoffee gtcoffee在gmail.com
星期二 十一月 13 19:41:27 HKT 2007

我昨天剛看了Djangobook, 應該只是 {% endblock %} 而不是 {%  
endblock main %}

On Nov 12, 2007, at 11:31 PM, huang jayven wrote:

> 请教大家一个问题,如果将block嵌到ifequal里头的 
> 话,貌似是不起作用的,文档里有没有什么地方有 
> 说明这样的原因?
>
> ################## father.html ##################
> 
> 
> {% ifequal a 0 %}
>     {% block main %}
>         father here
>     {% endblock main %}
> {% endifequal %}
> 
> 
>
> ################## child.html ###################
> {% extends "father.html" %}
>
> {% block main %}
>     child here
> {% endblock main %}
>
> ##############################################
> >>> from django.template.loader import render_to_string
> >>>
> >>> print render_to_string('father.html', {'a': 0})
> 
> 
>
>
> father here
>
>
> 
> 
>
> >>> print render_to_string('child.html', {'a': 0})
> 
> 
>
>
> father here
>
>
> 
> 
>
> >>>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese- 
> request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月14日 星期三 14:03

huang jayven kassarar在gmail.com
星期三 十一月 14 14:03:14 HKT 2007

ºÃÏñÕâ¸öû¹ØϵµÄ°É

ÔÚ07-11-13£¬GTcoffee <gtcoffee at gmail.com> дµÀ£º
>
> ÎÒ×òÌ섂¿´ÁËDjangobook, ‘ªÔ“Ö»ÊÇ {% endblock %} ¶ø²»ÊÇ {%
> endblock main %}
>
> On Nov 12, 2007, at 11:31 PM, huang jayven wrote:
>
> > Çë½Ì´ó¼ÒÒ»¸öÎÊÌ⣬Èç¹û½«blockǶµ½ifequalÀïÍ·µÄ
> > »°£¬Ã²ËÆÊDz»Æð×÷Óõģ¬ÎĵµÀïÓÐûÓÐʲôµØ·½ÓÐ
> > ˵Ã÷ÕâÑùµÄÔ­Òò£¿
> >
> > ################## father.html ##################
> > 
> > 
> > {% ifequal a 0 %}
> >     {% block main %}
> >         father here
> >     {% endblock main %}
> > {% endifequal %}
> > 
> > 
> >
> > ################## child.html ###################
> > {% extends "father.html" %}
> >
> > {% block main %}
> >     child here
> > {% endblock main %}
> >
> > ##############################################
> > >>> from django.template.loader import render_to_string
> > >>>
> > >>> print render_to_string('father.html', {'a': 0})
> > 
> > 
> >
> >
> > father here
> >
> >
> > 
> > 
> >
> > >>> print render_to_string('child.html', {'a': 0})
> > 
> > 
> >
> >
> > father here
> >
> >
> > 
> > 
> >
> > >>>
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-
> > request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20071114/3bc1acdc/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月15日 星期四 00:30

twinsant twinsant在gmail.com
星期四 十一月 15 00:30:31 HKT 2007

文档里没有说明,吃了亏才知道不能这么做.也许可以做为bug提交吧

On 11/13/07, huang jayven <kassarar在gmail.com> wrote:
> 请教大家一个问题,如果将block嵌到ifequal里头的话,貌似是不起作用的,文档里有没有什么地方有说明这样的原因?
>
> ################## father.html ##################
> 
> 
> {% ifequal a 0 %}
>     {% block main %}
>         father here
>     {% endblock main %}
> {% endifequal %}
> 
> 
>
> ################## child.html ###################
> {% extends "father.html" %}
>
> {% block main %}
>     child here
> {% endblock main %}
>
> ##############################################
> >>> from django.template.loader import render_to_string
> >>>
> >>> print render_to_string('father.html', {'a': 0})
> 
> 
>
>
> father here
>
>
> 
> 
>
> >>> print render_to_string('child.html', {'a': 0})
> 
> 
>
>
> father here
>
>
> 
> 
>
> >>>
>


-- 
你的生活,我们的梦想。

好看簿:上传照片,乐趣才刚刚开始……
http://www.haokanbu.com

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号