[Zope] My first question.

Paul Winkler pw_lists at slinkp.com
Wed Dec 3 17:19:16 EST 2003


On Wed, Dec 03, 2003 at 02:36:21PM -0700, Goldthwaite, Joe wrote:
> Mystery solved.   I looked at the html source like you suggested and it
> looked fine.  It's not quoting the rest of the page.  What's happening is
> the IS_YTD_Header is a TABLE column header.  When I put the DTML method in
> as a ZPT, it automatically closed the table tag.  Now all the data that
> would have been in the table is being strung together in one big string that
> looks a lot like quoted html.  I guess the ZPT stuff is trying to help me by
> forcing the closing tags but I wish it wouldn't.  Its help is getting in the
> way.
> 
> Here's another problem that seems to be related.  Maybe someone can show me
> a good way of doing it.  I have a flag coming in from my data that indicates
> whether or not to make the line bold.  The only way I know of to make it
> bold is to put <b> and </b> tags around the text.  I tried using a
> tal:condition statement in my repeat loop like this;
> 
>        <p tal:condition="python:item.Flags == 'B'" tal:omit-tag=""><b></p>
>        <td tal:content="item/desc">desc</td>
>        <p tal:condition="python:item.Flags == 'B'" tal:omit-tag=""></b></p>

That's not valid nesting, hence the compilation error.

> This is trivial to do in Python.  I know I'm supposed to separate
> presentation from logic but doing the formatting in HTML or TAL seems so
> much harder. I'm starting to think it may be better to just return the HTML
> from my function all ready to display.

better to learn how to use ZPT :-)

Here's one solution:
...
  <td>
    <b tal:omit-tag="python:item.Flags !='B'"
       tal:content="item/desc"> 
         Description of the item
    </b>
  </td>
...

Here's another solution, using css classes:


<head>
...
<style type="text/css">

.darker {font-weight: bold}

</style>
...
</head>
<body>
...

  <td>
    <span tal:class="python:item.Flags=='B' and 'darker' or nothing"
          tal:content="item/desc"> 
         Description of the item
    </span>
  </td>
...
</body>

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's FUZZY TROMBONIST BLOODLOSS!
(random hero from isometric.spaceninja.com)



More information about the Zope mailing list