Hi Robert,

I've had some similar issues. When my XML editor (or HTML editor) requires the source to be well-formed, I just use the first case you suggestion.

The other alternative is to use a macro to abstract out the entire input block. It's not well-formed XML, but it's more easily parseable.

#input ($isChecked)

You could put this in XML comments I suppose

<!--
#input ($isChecked)
-->

and have the macro stop and start the comments

#macro (input $condition)
-->
<input ... #if($condition)checked="checked"#end/>
<!--
#end

WILL

----- Original Message ----- From: "Robert Koberg" <[EMAIL PROTECTED]>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Tuesday, March 29, 2005 10:13 AM
Subject: templs in XML: how to hande input/@checked="checked"



Hi,

Given that my templates must exist in a well-formed XML document, I was wondering if velocity had a mechanism to handle the following:

#if ($isChecked)
  <input ... checked="checked"/>
#else
  <input .../>
#end

Since I need well-formed markup I cannot do:

<input ... #if($isChecked)checked="checked"#end/>

?

Someone turned me on to PXTL (http://www.doxdesk.com/pxtl/), a python templating language built with XML in mind. In PXTL you would handle the above with:

<input ... checked="checked{?px_if isChecked?}"/>

In other words, if the test fails, the templating engine removes the checked attribute node while still allowing for well-formedness.

Anything like this in velocity?

thanks,
-Rob

---------------------------------------------------------------------
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