Re: [Rest2web-develop] processing uservalues as a test condition in a template
Brought to you by:
mjfoord
|
From: Michael F. <fuz...@vo...> - 2008-03-22 18:02:59
|
Hello Ben,
I think the syntax you want is something like:
<#
if ocalnavbar == 'yes':
print_details(default_section, page_title='', item_wrapper='<div
class="rightbox"><h2>Articles</h2><ul>%s</ul></div>',
do_description=False)
else:
print "<!-- nope -->"
#>
Michael
Ben wrote:
> Hello,
>
> First of all, thank you very much for rest2web, again and again, that's
> a great piece of software for maintaining websites with ReStructuredText!
>
> I'm afraid I've a very very silly question so I apologize in advance for
> such a request, however I'm a bit stuck.
>
> I've discovered that I actually can embedded some code in the
> ReStructured Text file, for instance, this syntax is valid and does what
> it has to do:
>
> --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
>
> My ReST doc
> =============
>
> .. raw:: html
>
> <# print_details(default_section, page_title='', item_wrapper='<div
> class="rightbox"><h2>Articles</h2><ul>%s</ul></div>',
> do_description=False) #>
>
> Some other stuff
> ----------------------------------
>
> --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
>
>
> However, instead of adding this code in my (numerous!) ReST files and
> mix code and content, I would like to have a specific value for that
> (for instance, a value such as 'localnavbar: yes' in the local pages
> uservalues) and process the condition on the template side.
> And I'm afraid this is a bit too audacious for me, could someone give me
> a hand?
>
> In my template, I tried:
>
> --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
>
> if <% localnavbar %>==yes:
> print_details(default_section, page_title='', item_wrapper='<div
> class="rightbox"><h2>Articles</h2><ul>%s</ul></div>',
> do_description=False)
> else:
> print "<!-- nope -->"
> #>
>
> --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
>
> r2w complains a lot about <% localnavbar %> as an invalid syntax. I
> monkey-like tried thispage['localnavbar'] etc. but without success. I
> think I'm clearly missing something from:
> http://www.voidspace.org.uk/python/rest2web/reference/uservalues.html
> but I cand find what!
>
> Any help would be much appreciated.
> Many thanks,
>
> -- Ben
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Rest2web-develop mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/rest2web-develop
>
|