Ben Spead · Nov 20, 2015

How do you to a lone ">" in an &html<> block?

I am using &html<> to output some CSS to my page (which is a class-based and not a tag-based page), and the selectors contain the '>' character which the compiler chokes on.  How can I escape the '>' so it still displays as such in the web page source but doesn't trip up the compiler?

This is for 2012.2 btw.

0 398
Discussion (8)2
Log in or sign up to continue

You can manually escape ">" with "&gt;". A more generic approach is to escape your CSS with ..EscapeHTML().

Note - I found a really cool feature in the latest version of Caché:

So I could use a marker of &html[<my text here>] and it should work because a single > will not a an ending bracket.  

However, I am currently stuck on Caché 2012.2.  Does anyone know a way to do this on an older version?

Stefan - thanks for the feedback.  I originally tried &gt; but the problem is that then it writes out to the page as exactly as &gt; so it is not a valid CSS selector.  

I need it unescaped in my CSS in order to make it valid.  So is there a way to have it not break the compiler but still print out in the source as ">"?


&html< stuff here> w ">" &html <more stuff>


I like putting CSS in an XDATA block and then outputting it using AppS.Projection.CSS or using the XData definition object.

@Derek, that seems ugly. 

Much nicer (well .. maybe;) ):


Well, if you want pretty... how about  &html<#(">")#>

Thank you both!

Derek - Your second solution doesn't compile for some reason (that was my next try after I saw that &gt; didn't work).  Your first solution is what I had (temporarily) settled for but it put the > on a new line so it was really ugly in the source (and I wasn't sure if line breaks in CSS selectors was valid)

Fabian - your solution works very nicely, thank you!!

I just checked this on 16.2. The compiler does not complain about the ">" character in selectors:


<style type="text/css">
        .SourceFile > div{
color: black; background: #EEEEEE; font-size: 12pt;