Written by

Manager, Application Services at InterSystems
Question 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.

Comments

Stefan Wittmann · Nov 20, 2015

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

0
Ben Spead · Nov 20, 2015

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

0
Derek Day · Nov 20, 2015

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

0
Fabian Haupt · Nov 20, 2015

@Derek, that seems ugly. 

Much nicer (well .. maybe;) ):

&html<#($C(62))#>

0
Derek Day  Nov 20, 2015 to Fabian Haupt

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

0
Ben Spead · Nov 20, 2015

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

0
Stefan Wittmann · Nov 20, 2015

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

&html<

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