Marker attributes (without ="")

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Marker attributes (without ="")

Jan Goyvaerts
Consider the markup in a template:

<bar:item name="Bar" active/>

Thymeleaf will complain rightly about active not having a value. I've seen this kind of markup before, and I've seen Thymeleaf even generating it.

Unfortunately I can't seem to make Thymeleaf accept it for its own templates.

Can this be set in some way ? For example that the value is null or "" ?

TIA !

Jan
Reply | Threaded
Open this post in threaded view
|

Re: Marker attributes (without ="")

Zemi
Administrator
Thymeleaf usually speaks well-formed XML, so every attribute must have a value.

In XHTML is usual to repeat the attribute name as its value, like in
     <option selected="selected">

Although I've not tested it, maybe you might got it working using TemplateMode LEGACYHTML5.
Reply | Threaded
Open this post in threaded view
|

Re: Marker attributes (without ="")

danielfernandez
Administrator
In reply to this post by Jan Goyvaerts
As Zemi says, Thymeleaf (or more exactly, the template modes that come out-of-the-box with Thymeleaf) will expect you to write code that is well-formed from an XML standpoint. The LEGACYHTML5 template mode will allow you to process attributes without a value, but will not be able to produce the same kind of markup as output (will output active="", which is the equivalent).

The future 3.0 version of thymeleaf (which will come after 2.1) will include big changes in its markup parsing system, using attoparser [ http://www.attoparser.org ] and allowing the use of non-XML-well-formed code seamlessly.

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Marker attributes (without ="")

Jan Goyvaerts
I'll try that next week. Thanks !

Happy Easter everybody ! :-)


On Fri, Mar 29, 2013 at 3:38 PM, danielfernandez [via Thymeleaf - User Forum] <[hidden email]> wrote:
As Zemi says, Thymeleaf (or more exactly, the template modes that come out-of-the-box with Thymeleaf) will expect you to write code that is well-formed from an XML standpoint. The LEGACYHTML5 template mode will allow you to process attributes without a value, but will not be able to produce the same kind of markup as output (will output active="", which is the equivalent).

The future 3.0 version of thymeleaf (which will come after 2.1) will include big changes in its markup parsing system, using attoparser [ http://www.attoparser.org ] and allowing the use of non-XML-well-formed code seamlessly.

Regards,
Daniel.



If you reply to this email, your message will be added to the discussion below:
http://forum.thymeleaf.org/Marker-attributes-without-tp4025828p4025833.html
To unsubscribe from Marker attributes (without =""), click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Marker attributes (without ="")

Jan Goyvaerts
In reply to this post by danielfernandez
It works okay in legacy mode - but then so do gross syntax errors. :-)

I'd rather have attributes assigned an ignored value than allow all sorts of errors that are being worked on silently. The former will work while the latter has the danger of introducing bugs.

Can't I introduce a new template mode, especially for those ? Just kidding. ;-)

Thanks,

Jan