From commits-return-3677-archive-asf-public=cust-asf.ponee.io@velocity.apache.org Fri Apr 5 14:49:59 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2833A18060F for ; Fri, 5 Apr 2019 16:49:58 +0200 (CEST) Received: (qmail 57530 invoked by uid 500); 5 Apr 2019 14:49:58 -0000 Mailing-List: contact commits-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@velocity.apache.org Delivered-To: mailing list commits@velocity.apache.org Received: (qmail 57521 invoked by uid 99); 5 Apr 2019 14:49:58 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Apr 2019 14:49:58 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id B155A3A005D for ; Fri, 5 Apr 2019 14:49:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1857011 - in /velocity/site/cms/trunk/content/engine: 2.1/configuration.mdtext 2.1/user-guide.mdtext devel/configuration.mdtext devel/user-guide.mdtext Date: Fri, 05 Apr 2019 14:49:57 -0000 To: commits@velocity.apache.org From: cbrisson@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20190405144957.B155A3A005D@svn01-us-west.apache.org> Author: cbrisson Date: Fri Apr 5 14:49:57 2019 New Revision: 1857011 URL: http://svn.apache.org/viewvc?rev=1857011&view=rev Log: [site/engine] #if() empty checks clarification Modified: velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext velocity/site/cms/trunk/content/engine/devel/configuration.mdtext velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext Modified: velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext Fri Apr 5 14:49:57 2019 @@ -122,17 +122,17 @@ The following tree gathers all non depre **`directive.if.empty_check = true`** -> When evaluating if a reference resolves to `true` or `false` in a boolean context, the engine first checks if its value is null, if it is a Boolean or if it has a getAsBoolean() method. Then, if none of this applies, the behavior depends upon this configuration flag: +> When evaluating if a reference resolves to `true` or `false` in a boolean context, the engine first checks if its value is `null`, if it is a `Boolean` or if it has a public `getAsBoolean()` method. Then, if none of this applies, the behavior depends upon this configuration flag: > > - if `directive.if.empty_check` is `false`, no further check is performed and the object resolves to `true`. > - if `directive.if.empty_check` is `true`, the object is check for emptiness and zero value: > - return whether an array is empty. -> - return whether isEmpty() is false (covers String and all Collection classes). -> - return whether length() is zero (covers CharSequence classes other than String). -> - returns whether size() is zero (covers all Collections classes). -> - return whether a Number *strictly* equals zero. -> - return whether the result of getAsString() is empty (and false for a null result) if it exists. -> - return whether the result of getAsNumber() *strictly* equals zero (and false for a null result) if it exists. +> - return whether a public `isEmpty()` method exists and evaluates to false (`String`, `Collection`, etc). +> - return whether a public `length()` method exists and evaluates to zero (`CharSequence`, etc). +> - return whether a public `size()` method exists and evaluates to zero. +> - return whether a `Number` *strictly* equals zero. +> - return whether a public `getAsString()` method exists and evaluates to null or an empty string. +> - return whether a public `getAsNumber()` method exists and evaluates to null or *strictly* zero. ### #include() and #parse() Directives Modified: velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext Fri Apr 5 14:49:57 2019 @@ -503,9 +503,9 @@ The variable *$foo* is evaluated to dete + *$foo* is a boolean (true/false) which has a true value + *$foo* is a string or a collection which is not null **and** not empty + *$foo* is a number which is not equal to zero -+ *$foo* is an object (other than a string, a number or a collection) which is not null ++ *$foo* is an object (other than a string, a number or a collection) which is not null (and for which the standard public methods for querying the object size, length or boolean/string representations, if they exist, indicate a non-empty, non-zero, non-false object). -(please note that this is the default behavior, but Velocity can be configured to [skip all checks beyond boolean and nullity ones](configuration.html#if-directive)). +Please check the [#if directive configuration section](configuration.html#if-directive) for implementation details. This section also explains how to change this default behavior so that Velocity skips all checks beyond boolean and nullity ones. To test if a reference has a special values, you can use: @@ -1226,9 +1226,10 @@ There is a property, meant to be used in which defaults to false. When set to true *along with* - `resource.loader..cache = false` -(where is the name of the resource loader that you are using, such as 'file') then the Velocity engine will automatically reload changes to your Velocimacro library files when you make them, so you do not have to dump the servlet engine (or application) or do other tricks to have your Velocimacros reloaded. + `resource.loader..cache = false` + +(where is the name of the resource loader that you are using, such as 'file') then the Velocity engine will automatically reload changes to your Velocimacro library files when you make them, so you do not have to dump the servlet engine (or application) or do other tricks to have your Velocimacros reloaded. Here is what a simple set of configuration properties would look like. Modified: velocity/site/cms/trunk/content/engine/devel/configuration.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/devel/configuration.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/devel/configuration.mdtext (original) +++ velocity/site/cms/trunk/content/engine/devel/configuration.mdtext Fri Apr 5 14:49:57 2019 @@ -122,17 +122,17 @@ The following tree gathers all non depre **`directive.if.empty_check = true`** -> When evaluating if a reference resolves to `true` or `false` in a boolean context, the engine first checks if its value is null, if it is a Boolean or if it has a getAsBoolean() method. Then, if none of this applies, the behavior depends upon this configuration flag: +> When evaluating if a reference resolves to `true` or `false` in a boolean context, the engine first checks if its value is `null`, if it is a `Boolean` or if it has a public `getAsBoolean()` method. Then, if none of this applies, the behavior depends upon this configuration flag: > > - if `directive.if.empty_check` is `false`, no further check is performed and the object resolves to `true`. > - if `directive.if.empty_check` is `true`, the object is check for emptiness and zero value: > - return whether an array is empty. -> - return whether isEmpty() is false (covers String and all Collection classes). -> - return whether length() is zero (covers CharSequence classes other than String). -> - returns whether size() is zero (covers all Collections classes). -> - return whether a Number *strictly* equals zero. -> - return whether the result of getAsString() is empty (and false for a null result) if it exists. -> - return whether the result of getAsNumber() *strictly* equals zero (and false for a null result) if it exists. +> - return whether a public `isEmpty()` method exists and evaluates to false (`String`, `Collection`, etc). +> - return whether a public `length()` method exists and evaluates to zero (`CharSequence`, etc). +> - return whether a public `size()` method exists and evaluates to zero. +> - return whether a `Number` *strictly* equals zero. +> - return whether a public `getAsString()` method exists and evaluates to null or an empty string. +> - return whether a public `getAsNumber()` method exists and evaluates to null or *strictly* zero. ### #include() and #parse() Directives Modified: velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext (original) +++ velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext Fri Apr 5 14:49:57 2019 @@ -503,9 +503,9 @@ The variable *$foo* is evaluated to dete + *$foo* is a boolean (true/false) which has a true value + *$foo* is a string or a collection which is not null **and** not empty + *$foo* is a number which is not equal to zero -+ *$foo* is an object (other than a string, a number or a collection) which is not null ++ *$foo* is an object (other than a string, a number or a collection) which is not null (and for which the standard public methods for querying the object size, length or boolean/string representations, if they exist, indicate a non-empty, non-zero, non-false object). -(please note that this is the default behavior, but Velocity can be configured to [skip all checks beyond boolean and nullity ones](configuration.html#if-directive)). +Please check the [#if directive configuration section](configuration.html#if-directive) for implementation details. This section also explains how to change this default behavior so that Velocity skips all checks beyond boolean and nullity ones. To test if a reference has a special values, you can use: