On Thu, Mar 09, 2006 at 12:34:30AM -0300, Roger Demetrescu wrote:
> 
> Hello all !
> 
> CSS widget is rendered this way:
> 
> >>> css = CSSLink(mod=static, name="sample.css")
> >>> css.render()
> '<LINK HREF="/tg_widgets/turbogears.widgets/sample.css"
> TYPE="text/css" REL="stylesheet">'
> 
> 
> 
> Well, I'd like to be able to render something like:
> 
> '<LINK HREF="/tg_widgets/turbogears.widgets/sample.css"
> TYPE="text/css" REL="stylesheet" MEDIA="printer">'
> 
> ...but "media" actually isn't a valid argument.
> 
> >>> css = CSSLink(mod=static, name="sample.css", media="printer")

Usually the proper method to do this is overriding attrs variable at
render/display time:

>>> a = CSSLink(mod=static, name="sample.css")
>>> a.render(attrs=dict(media='printer'))

Problem is that CSSLink does have to be changed.  Line 621:

    template = '<link rel="stylesheet" type="text/css" href="$link"/>'

needs to become

    template = '<link rel="stylesheet" type="text/css" href="$link"
py:attrs="attrs"/>'

I bet if you asked nicely, someone with commit privs would do it for you.

Jason

-- 
If you understand, things are just as they are.  If you do not understand,
things are just as they are.

Attachment: pgpBgNzMt8ZAV.pgp
Description: PGP signature

Reply via email to