Ahh, good to know. It's nothing I've ever tried, but I just assumed would work. In that case, I'd go with Robert's suggestions (since they'll actually work).
-- Kevin On 2/15/08 2:55 PM, "Robert Zeigler" <[EMAIL PROTECTED]> wrote: > Expansions won't work (directly) for the asset, b/c expansions inside > of comments are ignored, so trying to do something like: > <!-- [if IE 6]> > <link rel="stylesheet" href="${asset:context:/foo/bar.css}"/> > <![endif]--> > > Isn't going to work. > > What you /could/ do is to have the entire comment generated in java > code, and then have all of the comment spit out as an expanded string > in your template. > Quick and dirty, but it'll work. > Something like: > > .java: > > @Inject > @Path("$path/to/css/default.css") > private Asset _defaultStyle; > > public String getConditionalComment() { > return "<!--[if IE 6]>\n<link rel='stylesheet' href='" + > _defaultStyle.toClientURL() + "'/>\n<![endif]-->"; > } > > .tml: > > ${conditionalComment} > > > > Perhaps a nicer way of doing this would be to "componetize" the > behavior. > You could create a ConditionalComment component which would wrap it's > body in the conditional comments, with a string parameter representing > the condition. > Something like: > > ConditionalComment.java: > > @Parameter(required=true,defaultPrefix="literal") > private String _condition; > > private void beginRender(MarkupWriter writer) { > writeRaw("<!--[if "); > writeRaw(_condition); > writeRaw("]>\n"); > } > > private void endRender(MarkupWriter writer) { > writeRaw("<![endif]-->"); > } > > Then your templates that need conditional comments could look like: > > <t:ConditionalComment condition="IE 6"> > <link href="..." rel="stylesheet"/> > </t:ConditionalComment> > > > The above code is, of course, untested, but should convey the general > idea. > > Cheers, > > Robert > > On Feb 15, 2008, at 2/1512:57 PM , Kevin Menard wrote: > >> You could just use an expansion in your template for the asset. Not >> quite >> the same, but it would accomplish the same goal. >> >> -- >> Kevin >> >> >> On 2/15/08 12:28 PM, "lebenski" <[EMAIL PROTECTED]> wrote: >> >>> >>> Hi guys, >>> >>> Does anyone know of a mechanism of utilizing IE Conditional >>> Comments for >>> importing browser-specific CSS, but using the standard tapestry >>> method of >>> css injection via the page class, i.e. something like: >>> >>> private PageRenderSupport _pageRenderSupport; >>> >>> @Inject >>> @Path("$path/to/css/default.css") >>> private Asset _defaultStyle; >>> >>> ... >>> >>> _pageRenderSupport.addStylesheetLink(_defaultStyle,null); >>> >>> Cheers, >>> Ben. >> >> >> --------------------------------------------------------------------- >> 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]