No, the {{include}} and {{extend}} directives are part of the template 
language -- they are not Python code. So, they are processed before 
executing any Python code. When the template is parsed, all of the includes 
and extends are processed in order to build a single template string. The 
template code is converted to Python, and only then does all the Python get 
executed. So, an "if" statement can be used to determine whether a 
particular section of included template code gets executed, but it does not 
prevent that template code from being included and parsed.

Anthony

On Wednesday, August 14, 2013 12:24:46 PM UTC-4, Annet wrote:
>
> Thank you both for your replies.
>
> Try it out, but I believe those are equivalent. They should both result in 
>> the same parsing to Python code -- the hero_shot.html view will be parsed 
>> into Python in both cases, and the "if" statement will simply determine 
>> whether that code actually gets executed (so, if you compile the app, both 
>> should result in the same compiled view code).
>>
>
> So the code in landingpage/hero_shot.html is included anyway , I thought 
> that maybe in this case:
>
> {{if landingpage.heroShot:}}
>   {{include 'landingpage/hero_shot.html'}}
> {{pass}}
>
> web2py doesn't bother to include the view, whereas in this case:
>
> {{include 'landingpage/hero_shot.html'}}
>
> it does include the view, just to find it's empty when there's no hero 
> shot.
>
> The landingpage/hero_shot.html is used in many layout views, that's the 
> reason why I
> excluded it from the layout.
>
>
> Kind regards,
>
> Annet
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to