You could create a simple component that optionally renders the div element. Something like:
public class IfDiv { @Parameter private boolean test; void setupRender(MarkupWriter writer) { if (test) writer.element("div"); } void afterRender(MarkupWriter writer) { if (test) writer.end(); } } Steve. On 7 August 2013 10:54, Dmitry Gusev <dmitry.gu...@gmail.com> wrote: > Or you can use blocks and delegate: > > <t:block id="contentBlock"> > Your content > </t:block> > > <t:if test="condition"> > <div class="cssclass"> > <t:delegate to="block:contentBlock" /> > </div> > <p:else> > <t:delegate to="block:contentBlock" /> > </p:else> > </t:if> > > On Wed, Aug 7, 2013 at 1:47 PM, Lance Java <lance.j...@googlemail.com > >wrote: > > > You'll have to use the OutputRaw component or MarkupWriter.writeRaw(...) > > > > Note that when passing the value parameter to OutputRaw you will need to > > escape <, > and " > > On 7 Aug 2013 10:33, "Nathan Quirynen" <nat...@pensionarchitects.be> > > wrote: > > > > > Hi, > > > > > > I want to add a div that wraps my content based on a condition: > > > > > > <t:if test="test"> > > > <div class="cssclass"> > > > </t:if> > > > > > > ... content ... > > > > > > <t:if test="test"> > > > </div> > > > </t:if> > > > > > > > > > This is not possible as it will give following exception: > > > > > > /org.xml.sax.**SAXParseException/ > > > /The element type "div" must be terminated by the matching end-tag > > > "</div>". > > > > > > /For my use case I can make a property for the css class and base it on > > > the condition: > > > > > > <div class="${cssClass}"> > > > ... content ... > > > </div> > > > > > > public String getCssClass() { > > > return test ? "cssclass" : ""; > > > } > > > > > > But I was just wondering if there is a way of adding a wrapping element > > > conditionally as I showed at the top. > > > > > > Nathan > > > > > > > > > > > > -- > Dmitry Gusev > > AnjLab Team > http://anjlab.com >