Perhaps you can use something like "if page.has_key('jsfiles')", the same
way that the "Basic wiki example"[1] checks for "if page.has_key('title')".

[1] http://webpy.org/src/wiki/0.3


On Sat, Jun 28, 2014 at 4:23 PM, Shannon Cruey <
[email protected]> wrote:

> Thanks, that works, however it leads me to another issue.  Evidently,
> after encountering a $:if, the templator never stops assuming indendation.
>  This isn't working for me, as it forces the code indentation to be off
> kilter.
>
> For example:
>
> $if content.get('cssfiles'):
>     $for f in content.cssfiles.split():
>         <link type="text/css" href="$f" rel="stylesheet" />
>
>     </head>
>     <body>
>         <nav id="app_header" class="top-bar" data-topbar>
>
>
> I only want the $:if to apply to the next few lines.  Not all the way down
> to the </head>.
>
> Know any way I can give the parser a 'hint' to stop reading downline
> indentation?
>
> I thought about using $else, but this isn't an else condition.
>
> Thanks!
> NSC
>
> On Sat, Jun 28, 2014 at 12:15 AM, Anand Chitipothu <[email protected]>
> wrote:
> >
> > On Sat, Jun 28, 2014 at 12:52 AM, NSC <[email protected]>
> wrote:
> >>
> >> I've always been slightly confused about how $var definitions work in a
> template, in regards to a base template. So, let me ask:
> >>
> >> In my 'sub' template (not base), I have something like this (straight
> from an example I found a year ago and lost):
> >>
> >> $var jsfiles: foo.js bar.js
> >>
> >> Then in the 'base' template I have this:
> >>
> >> $if content.jsfiles:
> >>     $for f in content.jsfiles.split():
> >>         <script src="$f"></script>
> >>
> >> Problem is, this approach *requires* each subtemplate to have $var
> jsfiles: even if I have no scripts to load for that page.
> >>
> >> Reading the code, I can't find a way to 'test' for the existence of a
> variable.  The page simply always throws a nasty error if the subpage
> doesn't define $var jsfiles:
> >>
> >> Anyone come up with a workaround for this?
> >
> >
> > You could do this:
> >
> > $if content.get('jsfiles'):
> >     $for f in content.jsfiles.split():
> >         <script src="$f"></script>
> >
> > Anand
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "web.py" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/webpy.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Marios Zindilis

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to