Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JET FAQ What are the JET whitespace handling rules?

Revision as of 10:23, 11 July 2007 by Pelder.ca.ibm.com (Talk | contribs) (Answer)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Question

Does JET do anything to remove whitespace (and particularly new lines) from a template? Sometimes I get unwanted new lines in my template results, and sometimes I do not. It seems very unpredictable.

Answer

JET does have rules for removing new lines from the template results. Here they are:

1) JET will only CONSIDER removing whitespace if a language element (scriptlet, expression, declaration, directive, open tag, end tag, empty tag, comment) is 'alone' on a line. Technically, this is implemented as the element starts on a line in which preceding text in only whitespace, and ends on a line that is only whitespace. So, for example, the following are all 'alone' on a line:

      <c:iterate select="..." var="...">
      <%-- this is a multiline comment,
      but it is still 'alone' on a line --%>

2) For scriptlets, declarations, directives and comments, being alone on a line will cause JET to remove the surrounding whitespace, including new-line characters at the end of the trailing line.

3) For JET custom tags, which space removal is dependent on that tag. Each tag is declared with a 'whenContainingLineIsEmpty' attribute, which can have a value of either 'preserve' or 'remove'. Typically, tags that produce content preserve, while those that provide control structure like capabilities remove. Some examples of whitespace preserving tags: c:get, f:lc (lowercase). Examples of whitespace removing tags: c:iterate, c:if, c:include.


Back to the M2T-JET-FAQ

Copyright © Eclipse Foundation, Inc. All Rights Reserved.