Mailing List Archive

Need some newbie tal help
I have a table and I am putting data into the cells using tal. I want to
bold the data under a certain condition. I tried this, but it didn't work:

<td tal:content="string:${player/name}"><b
tal:condition="python:str(player['name']) == 'Team'">name</b></td>

The data (player/name) appears correctly, but when player/name='Team', the
text is not bold. After some reading, I believe what is happening is that
the tal:content tag is replacing everything between the <td> and the </td>
tags. Is this correct? I tried this, and no bold either:

<td tal:content="string:${player/GP}"><b>GP</b></td>

which supports my hypothesis about the tal:content tag.

How do I add some "conditional bold effect" in my table data?

Mark
Re: Need some newbie tal help [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/05/2010 01:20 PM, Mark Phillips wrote:
> I have a table and I am putting data into the cells using tal. I want to
> bold the data under a certain condition. I tried this, but it didn't work:
>
> <td tal:content="string:${player/name}"><b
> tal:condition="python:str(player['name']) == 'Team'">name</b></td>
>
> The data (player/name) appears correctly, but when player/name='Team', the
> text is not bold. After some reading, I believe what is happening is that
> the tal:content tag is replacing everything between the <td> and the </td>
> tags. Is this correct? I tried this, and no bold either:
>
> <td tal:content="string:${player/GP}"><b>GP</b></td>
>
> which supports my hypothesis about the tal:content tag.
>
> How do I add some "conditional bold effect" in my table data?

You are correct that 'tal:content' on a wrapper element replaces any
markup in the children. You want to use 'tal:content' on the 'b' tag
itself, and then 'tal:omit-tag' to drop the element (but not its
contents). See:

http://wiki.zope.org/ZPT/TALSpecification14#omit-tag


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver@palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyrX78ACgkQ+gerLs4ltQ4tRQCfU0DN0AVeBSRg/wYjYFGcbAJL
8pUAn3x/KD8/qXdp4acpcIluuVnWvtrv
=l0+r
-----END PGP SIGNATURE-----

_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Need some newbie tal help [ In reply to ]
+-------[ Mark Phillips ]----------------------
| I have a table and I am putting data into the cells using tal. I want to bold the data under a certain condition. I tried this,
| but it didn't work:
|
| <td tal:content="string:${player/name}"><b tal:condition="python:str(player['name']) == 'Team'">name</b></td>

Try using css

<td><div tal:replace="string:${player/name}" tal:attributes="class python:test(player['name'] == 'Team', 'someboldcss', '')" /></td>



--
Andrew Milton
akm@theinternet.com.au
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Need some newbie tal help [ In reply to ]
On 05/10/2010 18:20, Mark Phillips wrote:
> I have a table and I am putting data into the cells using tal. I want to
> bold the data under a certain condition. I tried this, but it didn't work:
>
> <td tal:content="string:${player/name}"><b
> tal:condition="python:str(player['name']) == 'Team'">name</b></td>
>
> The data (player/name) appears correctly, but when player/name='Team',
> the text is not bold. After some reading, I believe what is happening is
> that the tal:content tag is replacing everything between the <td> and
> the </td> tags. Is this correct? I tried this, and no bold either:
>
> <td tal:content="string:${player/GP}"><b>GP</b></td>

<td><b tal:content="player/GP"
tal:omit-tag="python:str(player['name']) != 'Team'">GP</b></td>

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Need some newbie tal help [ In reply to ]
+-------[ Andrew Milton ]----------------------
| +-------[ Mark Phillips ]----------------------
| | I have a table and I am putting data into the cells using tal. I want to bold the data under a certain condition. I tried this,
| | but it didn't work:
| |
| | <td tal:content="string:${player/name}"><b tal:condition="python:str(player['name']) == 'Team'">name</b></td>
|
| Try using css
|
| <td><div tal:replace="string:${player/name}" tal:attributes="class
| python:test(player['name'] == 'Team', 'someboldcss', '')" /></td>

s/tal:replace/tal:content/

--
Andrew Milton
akm@theinternet.com.au
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Need some newbie tal help [ In reply to ]
On Tue, Oct 5, 2010 at 10:28 AM, Andrew Milton <akm@theinternet.com.au>wrote:

> +-------[ Mark Phillips ]----------------------
> | I have a table and I am putting data into the cells using tal. I want to
> bold the data under a certain condition. I tried this,
> | but it didn't work:
> |
> | <td tal:content="string:${player/name}"><b
> tal:condition="python:str(player['name']) == 'Team'">name</b></td>
>
> Try using css
>
> <td><div tal:replace="string:${player/name}" tal:attributes="class
> python:test(player['name'] == 'Team', 'someboldcss', '')" /></td>
>

Is CSS preferred over using tal:omit for some reason? When would I use
tal:omit to add formatting to a table cell and when should I use CSS
instead?
Re: Need some newbie tal help [ In reply to ]
+-------[ Mark Phillips ]----------------------
|
|
| On Tue, Oct 5, 2010 at 10:28 AM, Andrew Milton <akm@theinternet.com.au> wrote:
|
| +-------[ Mark Phillips ]----------------------
| | I have a table and I am putting data into the cells using tal. I want to bold the data under a certain condition. I tried
| this,
| | but it didn't work:
| |
| | <td tal:content="string:${player/name}"><b tal:condition="python:str(player['name']) == 'Team'">name</b></td>
|
| Try using css
|
| <td><div tal:replace="string:${player/name}" tal:attributes="class python:test(player['name'] == 'Team', 'someboldcss', '')"
| /></td>
|
|
| Is CSS preferred over using tal:omit for some reason? When would I use tal:omit to add formatting to a table cell and when should
| I use CSS instead?

I think you want to use CSS. Later if you want to change from bold to
underlined or italics or rainbow, you can just change a CSS class,
instead of rebuilding your mark up.

--
Andrew Milton
akm@theinternet.com.au
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Need some newbie tal help [ In reply to ]
On Tue, Oct 5, 2010 at 10:42 AM, Andrew Milton <akm@theinternet.com.au>wrote:

> +-------[ Mark Phillips ]----------------------
> |
> |
> | On Tue, Oct 5, 2010 at 10:28 AM, Andrew Milton <akm@theinternet.com.au>
> wrote:
> |
> | +-------[ Mark Phillips ]----------------------
> | | I have a table and I am putting data into the cells using tal. I
> want to bold the data under a certain condition. I tried
> | this,
> | | but it didn't work:
> | |
> | | <td tal:content="string:${player/name}"><b
> tal:condition="python:str(player['name']) == 'Team'">name</b></td>
> |
> | Try using css
> |
> | <td><div tal:replace="string:${player/name}" tal:attributes="class
> python:test(player['name'] == 'Team', 'someboldcss', '')"
> | /></td>
> |
> |
> | Is CSS preferred over using tal:omit for some reason? When would I use
> tal:omit to add formatting to a table cell and when should
> | I use CSS instead?
>
> I think you want to use CSS. Later if you want to change from bold to
> underlined or italics or rainbow, you can just change a CSS class,
> instead of rebuilding your mark up.
>
> Thanks! good advice!