Tapestry 5
  1. Tapestry 5
  2. TAP5-1128

A space is added to a HTML start comment sequence making it impossible to add IE conditional comments

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.2.0
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      I tried to add an Internet Explorer conditional style to solve some rendering differences between IE and FF. To way to add conditional comments is by using the following syntax

      <!--[if IE]>
      Special instructions for IE here
      <![endif]-->

      The problem is that Tapestry adds a space between <!-- and [if IE]

      example: <Unable to render embedded object: File (--[if IE]> becomes <) not found.-- [if IE]> (note the added space)

      IE only accepts the conditional comment if there is no space between <!-- and [if IE]

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        There is an easy workaround: use the writeRaw() method.

        Show
        Howard M. Lewis Ship added a comment - There is an easy workaround: use the writeRaw() method.
        Hide
        Martijn Brinkers added a comment -

        Workaround (found on mailinglist) is to create a ConditionalComment component.

        Usage example:

        <!-- IE requires a change to the error style -->
        <t:ConditionalComment t:condition="IE">
        <style>
        HTML BODY DIV.t-error LI

        { margin-left: 20px; }

        </style>
        </t:ConditionalComment>

        package mitm.mimesecure.web.components;

        import org.apache.tapestry5.BindingConstants;
        import org.apache.tapestry5.MarkupWriter;
        import org.apache.tapestry5.annotations.AfterRender;
        import org.apache.tapestry5.annotations.BeginRender;
        import org.apache.tapestry5.annotations.Parameter;

        public class ConditionalComment
        {
        @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
        private String condition;

        @BeginRender
        public void beginRender(MarkupWriter writer)

        { writer.writeRaw("<!--[if "); writer.writeRaw(condition); writer.writeRaw("]>\n"); }

        @AfterRender
        public void afterRender(MarkupWriter writer)

        { writer.writeRaw("<![endif]-->"); }

        }

        Show
        Martijn Brinkers added a comment - Workaround (found on mailinglist) is to create a ConditionalComment component. Usage example: <!-- IE requires a change to the error style --> <t:ConditionalComment t:condition="IE"> <style> HTML BODY DIV.t-error LI { margin-left: 20px; } </style> </t:ConditionalComment> package mitm.mimesecure.web.components; import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.MarkupWriter; import org.apache.tapestry5.annotations.AfterRender; import org.apache.tapestry5.annotations.BeginRender; import org.apache.tapestry5.annotations.Parameter; public class ConditionalComment { @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL) private String condition; @BeginRender public void beginRender(MarkupWriter writer) { writer.writeRaw("<!--[if "); writer.writeRaw(condition); writer.writeRaw("]>\n"); } @AfterRender public void afterRender(MarkupWriter writer) { writer.writeRaw("<![endif]-->"); } }

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Martijn Brinkers
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development