Search

I'm a but stumped.

How can I achieve the following output where data-template has no value, but is required:

<div class="row" data-template> 

For a full explanation of why I want this, see tempo - a tiny JSON rendering engine

Thanks!

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.

Or, since I'm not a javascript wizard, you could suggest that they add that ability.

The developer added this functionality now. You should now able to use strict markup like so...

<div class="row" data-template="data-template">

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.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details