So it looks like one would need to (re)create something similar to the T4 Shell component. I've taken a brief look at the DOM api, and if I were to write something as focused as a Style component, then it looks like I'd have to:

1) create my component class, either in my.namespace.components, or another module that is loaded and contributed
2) get a MarkupWriter instance via void beginRender/@BeginRender
3) use writer.getRootElement() to get the root, and then traverse into the <head> 4) assuming eHead is my <head> Element, use eHead.element("link", "rel", "stylesheet", "type", "text/css", "href", "TODO-css-url-here"), to append a <link>

Can anyone comment on the (in)correctness of this?
It'd be nice to ensure ordering of the sheets somehow, so they can cascade properly. It'd be easier to do that with a more sophisticated Shell-link component that handled building the page base (head, metas, scripts, etc). Anyway, please share thoughts.

thanks
chris

Robert Zeigler wrote:
T5 renders with a dom.
Gives you a lot of control...
You could create a "style" component that finds the head and inserts the appropriate <link> element. Then your components could add their own stylesheets using the style component, with the page and containing components none the wiser. You would want to make sure that a given stylesheet is inserted only once, of course (eg, if your component is contained within a loop...).
A component like this should be very straightforward to write in T5.

Robert

On Aug 13, 2007, at 8/134:51 PM , Chris Lewis wrote:

One of the nice things I learned in my brief investigation of T4.1.2 was that the Shell component would automatically pick up any style sheets a page declared using the @Style annotation (or something like that). I've been wondering how something like this might be achieved in T5, using the available components as opposed to subclassing a base page. This seems like a feature that would be part of the core, as it is such a common need. I know I could emulate this by creating a layout that expected a page property, say externalCss (a collection), and using the Loop component to iterate it and insert the link elements. Is this the only way to do this in T5?

thanks!
chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to