Return-Path:
X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io
Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io
Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183])
by cust-asf2.ponee.io (Postfix) with ESMTP id DD924200CDB
for ; Sat, 5 Aug 2017 16:26:31 +0200 (CEST)
Received: by cust-asf.ponee.io (Postfix)
id DC05D16529F; Sat, 5 Aug 2017 14:26:31 +0000 (UTC)
Delivered-To: archive-asf-public@cust-asf.ponee.io
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by cust-asf.ponee.io (Postfix) with SMTP id 06CD9165298
for ; Sat, 5 Aug 2017 16:26:30 +0200 (CEST)
Received: (qmail 88718 invoked by uid 500); 5 Aug 2017 14:26:30 -0000
Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@freemarker.incubator.apache.org
Delivered-To: mailing list notifications@freemarker.incubator.apache.org
Received: (qmail 88709 invoked by uid 99); 5 Aug 2017 14:26:30 -0000
Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Aug 2017 14:26:30 +0000
Received: from localhost (localhost [127.0.0.1])
by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 32576C0032
for ; Sat, 5 Aug 2017 14:26:29 +0000 (UTC)
X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org
X-Spam-Flag: NO
X-Spam-Score: -4.222
X-Spam-Level:
X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31
tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5,
RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,
RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled
Received: from mx1-lw-eu.apache.org ([10.40.0.8])
by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024)
with ESMTP id JLJhf6fjMTRh for ;
Sat, 5 Aug 2017 14:26:27 +0000 (UTC)
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id BB3FB61B61
for ; Sat, 5 Aug 2017 14:26:24 +0000 (UTC)
Received: (qmail 86637 invoked by uid 99); 5 Aug 2017 14:26:23 -0000
Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Aug 2017 14:26:23 +0000
Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33)
id 2D75AF5EC9; Sat, 5 Aug 2017 14:26:22 +0000 (UTC)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: ddekany@apache.org
To: notifications@freemarker.incubator.apache.org
Date: Sat, 05 Aug 2017 14:26:44 -0000
Message-Id:
In-Reply-To: <39113a26e8294a41bc4f7377810a815e@git.apache.org>
References: <39113a26e8294a41bc4f7377810a815e@git.apache.org>
X-Mailer: ASF-Git Admin Mailer
Subject: [24/50] incubator-freemarker git commit: Added alternative syntaxes
for the && (logical and) operator: \and and & &
. These are to work around issues in applications where the template must be a
valid XML (&& is not valid XML/HTML, at most places),
archived-at: Sat, 05 Aug 2017 14:26:32 -0000
Added alternative syntaxes for the && (logical and) operator: \and and &&. These are to work around issues in applications where the template must be a valid XML (&& is not valid XML/HTML, at most places), or where the template entered is stored after XML or HTML escaping. Note that lonely &, and `and` without \ is not recognized for backward compatibility.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/f933ed03
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/f933ed03
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/f933ed03
Branch: refs/heads/2.3
Commit: f933ed03db875aa1f550e091339da6469e8cd6ba
Parents: 304df82
Author: ddekany
Authored: Wed Jun 28 11:29:28 2017 +0200
Committer: ddekany
Committed: Wed Jun 28 11:29:28 2017 +0200
----------------------------------------------------------------------
src/main/javacc/FTL.jj | 2 +-
src/manual/en_US/book.xml | 94 +++++++++++++++-----
.../test/templatesuite/templates/boolean.ftl | 4 +
3 files changed, 77 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f933ed03/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index c6a9d8b..75c7784 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -1251,7 +1251,7 @@ TOKEN:
|
|
-
+
|
|
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f933ed03/src/manual/en_US/book.xml
----------------------------------------------------------------------
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index a4d63a1..05435b0 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -3457,30 +3457,29 @@ ${12 % -5} <#-- Prints 2 -->
<#if (x > y)>, although it's considered
to be less elegant.
-
- FreeMarker supports some other alternatives too, but these
- are deprecated:
+ FreeMarker supports some more syntactical alternatives:
-
-
- Writing > and
- < on the place of the problematic
- relation marks, like in: <#if x >
- y> or <#if x >=
- y> . Note that in general FTL does not support
- entity references (the
- &...;
- things) in FTL tags; it's just an exception with the
- arithmetical comparisons.
-
+
+
+ > and
+ < can also be used, like in:
+ <#if x > y> or <#if
+ x >= y>. This isn't meant to be entered
+ manually; it's to work around cases where the template gets
+ XML/HTML escaped and the user can't easily prevent that
+ happening. Note that in general FTL does not support entity
+ references (the
+ &...; things)
+ in FTL tags; it's just an exception with these operators.
+
-
- \lt, \lte,
- \gt and \gte which are
- the same as the ones without the backslash
-
-
-
+
+ Deprecated forms: \lt,
+ \lte, \gt and
+ \gte. These are the same as the ones without
+ the backslash.
+
+
@@ -3535,6 +3534,38 @@ ${12 % -5} <#-- Prints 2 -->
<#if !hot> <#-- here hot must be a boolean -->
It's not hot.
</#if>
+
+ FreeMarker supports some more syntactical alternatives:
+
+
+
+ \and (since FreeMarker 2.3.27): In some
+ applications using && causes problems
+ as it's not valid in XML or HTML. While FreeMarker templates was
+ never intended to be valid XML/HTML, only their output should be
+ that, in reality there are some applications that expect the
+ template itself to be valid XML/HTML regardless. This syntax is
+ a workaround for such cases. Also note that unlike with the
+ comparison operators, and without
+ \ is not supported due to backward
+ compatibility restrictions.
+
+
+
+ && (since FreeMarker
+ 2.3.27): This isn't meant to be entered manually; it's to work
+ around cases where the template gets XML/HTML escaped and the
+ user can't easily prevent that happening. Note that in general
+ FTL does not support entity references (the
+ &...; things)
+ in FTL tags; it's just an exception with these operators.
+
+
+
+ Deprecated forms: & and
+ |. Don't use them anymore.
+
+
@@ -26856,6 +26887,25 @@ TemplateModel x = env.getVariable("x"); // get variable x
accepted (graduated) Apache project.
+ Changes on the FTL side
+
+
+
+ Added alternative syntaxes for the
+ && (logical and
)
+ operator: \and and
+ &&. These are to work around
+ issues in applications where the template must be a valid XML
+ (&& is not valid XML/HTML, at most
+ places), or where the template entered is stored after XML or
+ HTML escaping. Note that lonely &,
+ and and without \ is not
+ recognized for backward compatibility.
+
+
+
+
+
Changes on the Java side
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f933ed03/src/test/resources/freemarker/test/templatesuite/templates/boolean.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/boolean.ftl b/src/test/resources/freemarker/test/templatesuite/templates/boolean.ftl
index ab11c64..a76d9b9 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/boolean.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/boolean.ftl
@@ -71,6 +71,10 @@
<#else>
boolean4 && boolean5 failed.
#if>
+<@assert test=boolean4 && boolean5 />
+<@assert test=!(false && true) />
+<@assert test=boolean4 \and boolean5 />
+<@assert test=!(false \and true) />
Now test list models: