How to use HTML5 Boilerplate in a ZPT?

116 Views Asked by At

I'm trying to update one of our older ZPT based applications and I would like to implement the following HTML5 Boilerplate best practice for adding conditional IE classes to the <html>.

<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->

Since I've used this technique on many non-ZPT sites I didn't think too much about it, however when I went to implement it I ran into a few problems.

  1. ZPTs remove HTML comments so the rendered source lacks the conditional comments
  2. We're using a whole page macro to define a reusable page template and that definition occurs in the <html> element like so, <html metal:define-macro="page">. Even once I get the conditional comments to display it seems that my next hurdle will be properly defining the page macro.

Can anyone shed some light on either of these questions?

1

There are 1 best solutions below

0
On

It's estrange, zpt doesn't remove comments. Maybe it's a particular implementation of zpt who does that? Anyways, have you tried using tal:replace="strucutre string:...."

<metal:macro metal:define-macro="page">
<tal:doctype tal:replace="structure string:&lt;!DOCTYPE html&quot;&gt;" />
<!-- If the comments are eaten, you can generate them using the same trick that
     tal:doctype above -->

</metal:macro>