ZK LESS Syntax Notes"

From Documentation
(ZK-Less Syntax Notes)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{ZKStyleCustomizationGuidePageHeader}}
 +
 
= Be aware of using control-flow tags like <c:if> =
 
= Be aware of using control-flow tags like <c:if> =
  
 
If you are using control-flow tags like <c:if> in your ZK-Less files, you have to be really care with the situations like below:
 
If you are using control-flow tags like <c:if> in your ZK-Less files, you have to be really care with the situations like below:
  
<code>
+
<source lang="html">
 
  .z-selector {
 
  .z-selector {
 
       border-left-color: @border;
 
       border-left-color: @border;
Line 10: Line 12:
 
       </c:if>
 
       </c:if>
 
  }
 
  }
</code>
+
</source>
  
 
If '''@border''' and '''@border4IE8''' happens to be the same, Less will optimize them and only keep the last expression while compiling. Therefore, the above Less expression is equivalent to the following:
 
If '''@border''' and '''@border4IE8''' happens to be the same, Less will optimize them and only keep the last expression while compiling. Therefore, the above Less expression is equivalent to the following:
  
<code>
+
<source lang="html">
 
  .z-selector {
 
  .z-selector {
 
   // removed by less
 
   // removed by less
 
   <c:if test="${zk.ie == 8}">
 
   <c:if test="${zk.ie == 8}">
  border-left-color: red;
+
  border-left-color: red;
 
   </c:if>
 
   </c:if>
 
  }
 
  }
</code>
+
</source>
  
 
So, to be safe, please change the order of your Less expressions like this:
 
So, to be safe, please change the order of your Less expressions like this:
  
<code>
+
<source lang="html">
 
  .z-selector {
 
  .z-selector {
 
   <c:if test="${zk.ie == 8}">
 
   <c:if test="${zk.ie == 8}">
  border-left-color: @border4IE8;
+
  border-left-color: @border4IE8;
 
   </c:if>
 
   </c:if>
 
   border-left-color: @border;
 
   border-left-color: @border;
 
  }
 
  }
</code>
+
</source>
  
 
Here, when '''@border''' and '''@border4IE8''' are the same, the compiled CSS looks like:  
 
Here, when '''@border''' and '''@border4IE8''' are the same, the compiled CSS looks like:  
  
<code>
+
<source lang="html">
 
  .z-selector {
 
  .z-selector {
 
   <c:if test="${zk.ie == 8}">
 
   <c:if test="${zk.ie == 8}">
 
   </c:if>
 
   </c:if>
  border-left-color: red;
+
  border-left-color: red;
 
  }
 
  }
</code>
+
</source>
  
and if they are not the same, the result is:  
+
and if they are different, the result is:  
  
<code>
+
<source lang="html">
 
  .z-selector {
 
  .z-selector {
 
   <c:if test="${zk.ie == 8}">
 
   <c:if test="${zk.ie == 8}">
    border-left-color: red;
+
  border-left-color: red;
 
   </c:if>
 
   </c:if>
 
   border-left-color: rgba(rr,gg,bb,aa); // IE8 will ignore this  
 
   border-left-color: rgba(rr,gg,bb,aa); // IE8 will ignore this  
 
  }
 
  }
</code>
+
</source>
  
 
Remember to always place your control-flow tags first to avoid any possible errors like the example showed.
 
Remember to always place your control-flow tags first to avoid any possible errors like the example showed.
+
 
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}

Revision as of 04:42, 2 September 2014


Be aware of using control-flow tags like <c:if>

If you are using control-flow tags like <c:if> in your ZK-Less files, you have to be really care with the situations like below:

 .z-selector {
      border-left-color: @border;
      <c:if test="${zk.ie == 8}">
      border-left-color: @border4IE8;
      </c:if>
 }

If @border and @border4IE8 happens to be the same, Less will optimize them and only keep the last expression while compiling. Therefore, the above Less expression is equivalent to the following:

 .z-selector {
  // removed by less
  <c:if test="${zk.ie == 8}">
  border-left-color: red;
  </c:if>
 }

So, to be safe, please change the order of your Less expressions like this:

 .z-selector {
  <c:if test="${zk.ie == 8}">
  border-left-color: @border4IE8;
  </c:if>
  border-left-color: @border;
 }

Here, when @border and @border4IE8 are the same, the compiled CSS looks like:

 .z-selector {
  <c:if test="${zk.ie == 8}">
  </c:if>
  border-left-color: red;
 }

and if they are different, the result is:

 .z-selector {
  <c:if test="${zk.ie == 8}">
  border-left-color: red;
  </c:if>
   border-left-color: rgba(rr,gg,bb,aa); // IE8 will ignore this 
 }

Remember to always place your control-flow tags first to avoid any possible errors like the example showed.

Version History

Last Update : 2014/09/02


Version Date Content
     



Last Update : 2014/09/02

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.