HTML5 Custom data attributes
This is an open discussion with 9 replies, filed under XSLT.
Search
So far the only method I can see that works for me is:
<xsl:text disable-output-escaping="yes"><![CDATA[<div id="content" data-template>]]></xsl:text> ... <xsl:text disable-output-escaping="yes"><![CDATA[</div>]]></xsl:text>
It looks ugly but it works. If there is a more elegant solution I'm all ears!
@Fazal - did you try something like this...
<div class="row" data-template="data-template">
Actually, @Fazal, I got it to work with with an empty attribute...
<div class="row" data-template="">
Hi Brian, I also managed to get the empty attribute to work, although it seems a bit ugly. My output is HTML5 and ideally I'd like to keep the output clean too.
These type of boolean attributes can differ based on your doctype, so your first example would be fine for XHTML and the second fine for HTML.
I suppose I'm being a bit picky. I've cast the net a little wider to see what other suggestions we can find.
Because XSLT transforms XML (not HTML) the output will always be valid XML (not HTML). So the XSLT processor will only be capable of creating the attribute with an empty value (data-template=""
), unless you resort to the xsl:text
method. I thinks.
@Fazal - I'm sure there is a way to tweak the javascript to include the ability to not only use "naked" attributes (default) <div class="row" data-template>
, but also be able to react to strict markup... <div class="row" data-template="data-template">
.
Since the tempo developers have their code on github, if you are able to tweak it to add that ability you can make a pull request. Or, since I'm not a javascript wizard, you could suggest that they add that ability.
wow, positive action Brian!
I thought it would be good to discuss this, because at some point I guess when people really start to explore HTML5 these kind of issues would crop up.
I'm going to go for the correct method of using xsl:attribute
@Fazal, one of the developers of Tempo, Mr. Olafsson, is to thank for that. He was very responsive to our request, and responded very positively to it. Very cool. Thanks for letting us know about this app. I'm glad to know something like this is available.
Create an account or sign in to comment.
I'm a but stumped.
How can I achieve the following output where data-template has no value, but is required:
For a full explanation of why I want this, see tempo - a tiny JSON rendering engine
Thanks!