Comment 3 for bug 394011

Revision history for this message
Malthe Borch (mborch) wrote : Re: [Bug 394011] [NEW] enable the use string: ${foo | nothing} to avoid a KeyError

2009/7/1 Edwin Grubbs <email address hidden>:
> I guess my example was too simple to explain the problem I am having.
> Here is a better one.
>
> <script tal:content="string: do_something('${foo}', '${bar}', '${baz}')"
> />
>
> As you can see, I would have to have an alternate string for each
> combination of variables that could be undefined.

I think it's an abuse, but I see the general issue and actually I've
had this problem myself, something like:

<span tal:attributes="string:${some_class}
contenttype-${maybe_some_content_type | nothing}">...</span>

The second part should ideally be left out entirely, if not defined. Perhaps:

<span tal:attributes="string:${some_class}
${string:contenttype-${maybe_some_content_type} | nothing}">...</span>

could work?