Author: cbrisson Date: Sat Apr 8 21:56:14 2017 New Revision: 1790717 URL: http://svn.apache.org/viewvc?rev=1790717&view=rev Log: [site/engine] Update 2.0 pages from devel ones
Modified: velocity/site/cms/trunk/content/engine/2.0/configuration.mdtext velocity/site/cms/trunk/content/engine/2.0/dependencies.mdtext velocity/site/cms/trunk/content/engine/2.0/developer-guide.mdtext velocity/site/cms/trunk/content/engine/2.0/upgrading.mdtext velocity/site/cms/trunk/content/engine/2.0/user-guide.mdtext velocity/site/cms/trunk/content/engine/2.0/vtl-reference.mdtext Modified: velocity/site/cms/trunk/content/engine/2.0/configuration.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.0/configuration.mdtext?rev=1790717&r1=1790716&r2=1790717&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.0/configuration.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.0/configuration.mdtext Sat Apr 8 21:56:14 2017 @@ -66,9 +66,19 @@ Below are listed the configuration keys ### #if() Directive -**`directive.if.tostring.nullcheck = true`** +**`directive.if.emptycheck = true`** -> Default behavior is to check return value of toString() and treat an object with toString() that returns null as null. If all objects have toString() methods that never return null, this check is unnecessary and can be disabled to gain performance. In Velocity 1.5, no such null check was performed. +> 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: +> +> - if `directive.if.emptycheck` is `false`, no further check is performed and the object resolves to `true`. +> - if `directive.if.emptycheck` 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. ### #set() Directive Modified: velocity/site/cms/trunk/content/engine/2.0/dependencies.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.0/dependencies.mdtext?rev=1790717&r1=1790716&r2=1790717&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.0/dependencies.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.0/dependencies.mdtext Sat Apr 8 21:56:14 2017 @@ -8,12 +8,12 @@ The following table lists all needed jar Jar name | Version | Compilation | Tests | Runtime | Comment ---------|---------|---------|-------|-------------|-------- -slf4j-api | 1.7.21 | Yes | Yes | Yes | you'll also need an slf4j binding at runtime +slf4j-api | 1.7.25 | Yes | Yes | Yes | you'll also need an slf4j binding at runtime commons-lang | 3.5 | Yes | Yes | Yes | junit | 4.12 | No | Yes | No | hsqldb | 2.3.4 | No | Yes | No | commons-io | 2.5 | No | Yes | No | -slf4j-simple | 1.7.21 | No | Yes | No | Your application will need *one* SLF4J binding, see below +slf4j-simple | 1.7.25 | No | Yes | No | Your application will need *one* SLF4J binding, see below Here is a list of slf4j bindings: Modified: velocity/site/cms/trunk/content/engine/2.0/developer-guide.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.0/developer-guide.mdtext?rev=1790717&r1=1790716&r2=1790717&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.0/developer-guide.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.0/developer-guide.mdtext Sat Apr 8 21:56:14 2017 @@ -475,26 +475,26 @@ If we wanted to use a different director /* lets make a Context and put data into it */ ... - + And the same if you want to use a VelocityEngine object rather than the singleton engine: ... - + import java.util.Properties; ... public static void main( String args[] ) { /* first, we init the runtime engine. */ - + Properties p = new Properties(); p.setProperty("file.resource.loader.path", "/opt/templates"); VelocityEngine engine = new VelocityEngine(); engine.init( p ); /* lets make a Context and put data into it */ - - ... + + ... And, assuming you have a directory `/opt/templates` and the template `testtemplate.vm` is in there, then things would work just fine. If you try this and have a problem, be sure to look at the velocity.log for information - the error messages are pretty good for figuring out what is wrong. @@ -1052,6 +1052,7 @@ Since Velocity 2.0, besides the default <th>Long</th> <th>Float</th> <th>Double</th> + <th>Number</th> <th>String</th> <th>Object</th> <th>null</th> @@ -1067,6 +1068,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> </tr> @@ -1083,6 +1085,7 @@ Since Velocity 2.0, besides the default <td><span class="none">none</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> + <td><span class="none">none</span></td> </tr> <tr> <th>byte</th> @@ -1093,7 +1096,8 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> - <td><span class="none">none</span></td> + <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> @@ -1109,6 +1113,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> </tr> @@ -1123,6 +1128,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> </tr> @@ -1137,6 +1143,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> </tr> @@ -1151,6 +1158,7 @@ Since Velocity 2.0, besides the default <td><span class="implicit">implicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> </tr> @@ -1165,6 +1173,7 @@ Since Velocity 2.0, besides the default <td><span class="implicit">implicit</span></td> <td><span class="implicit">implicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> </tr> @@ -1179,6 +1188,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1194,6 +1204,7 @@ Since Velocity 2.0, besides the default <td><span class="none">none</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> + <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> <tr> @@ -1207,6 +1218,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1221,6 +1233,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1235,6 +1248,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1249,6 +1263,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1263,6 +1278,7 @@ Since Velocity 2.0, besides the default <td><span class="strict">strict</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1277,6 +1293,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="strict">strict</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> </tr> @@ -1290,6 +1307,7 @@ Since Velocity 2.0, besides the default <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> + <td><span class="strict">strict</span></td> <td><span class="none">none</span></td> <td><span class="none">none</span></td> <td><span class="strict">strict</span></td> @@ -1304,6 +1322,7 @@ Since Velocity 2.0, besides the default <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> <td><span class="explicit">explicit</span></td> + <td><span class="explicit">explicit</span></td> <td><span class="strict">strict</span></td> <td><span class="explicit">explicit</span></td> <td><span class="strict">strict</span></td> @@ -1313,6 +1332,7 @@ Since Velocity 2.0, besides the default <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> + <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> <td><span class="strict">strict</span></td> Modified: velocity/site/cms/trunk/content/engine/2.0/upgrading.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.0/upgrading.mdtext?rev=1790717&r1=1790716&r2=1790717&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.0/upgrading.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.0/upgrading.mdtext Sat Apr 8 21:56:14 2017 @@ -30,6 +30,7 @@ Read below for futher details. + Initialization methods in Velocity and VelocityEngine taking an ExtendedProperties have been removed (but `setProperties(Properties)` methods are still here). All occurences of the org.apache.commons.collections.ExtendedProperties class in the runtime internal initialization API have been replaced by org.apache.velocity.util.ExtProperties. + the macros are now using a 'call by sharing' convention (which means that all arguments are evaluated once at start, and that the macro receives a copy of the reference to each argument). + the `UberspectLoggable` interface has been removed. ++ the `directive.if.tostring.nullcheck` configuration property has been superseded by the `directive.if.emptycheck` property. ### VTL Changes: @@ -42,7 +43,7 @@ Read below for futher details. + Velocity now requires a JDK version of 1.7 or higher. + commons-collections and commons-logging aren't needed any more at runtime. -+ there's a new runtime dependency, slf4j-api 1.7.12. ++ there's a new runtime dependency, slf4j-api 1.7.25. + you'll need an [SLF4J binding](dependencies.html). + commons-lang has to be upgraded to 3.5. Modified: velocity/site/cms/trunk/content/engine/2.0/user-guide.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.0/user-guide.mdtext?rev=1790717&r1=1790716&r2=1790717&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.0/user-guide.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.0/user-guide.mdtext Sat Apr 8 21:56:14 2017 @@ -500,11 +500,14 @@ The *#if* directive in Velocity allows f <strong>Velocity!</strong> #end -The variable *$foo* is evaluated to determine whether it is true, which will happen under one of three circumstances: +The variable *$foo* is evaluated to determine whether it is true, which will happen under one of those circumstances: + *$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 an object (other than a string or a collection) which is not null ++ *$foo* is a number which equals to zero ++ *$foo* is an object (other than a string, a number or a collection) which is not null + +(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)). Remember that the Velocity context only contains Objects, so when we say 'boolean', it will be represented as a Boolean (the class). This is true even for methods that return `boolean` - the introspection infrastructure will return a `Boolean` of the same logical value. Modified: velocity/site/cms/trunk/content/engine/2.0/vtl-reference.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.0/vtl-reference.mdtext?rev=1790717&r1=1790716&r2=1790717&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.0/vtl-reference.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.0/vtl-reference.mdtext Sat Apr 8 21:56:14 2017 @@ -88,7 +88,18 @@ Format: Usage: -+ *condition* - If a boolean, considered true if it has a true false; if not a boolean, considered true if not null. ++ *condition* - Expression to evaluate. When tis result is null, evaluate to false. Otherwise, check for conversion towards Boolean and non-emptiness as follow: + - return its value for a Boolean object, or the result of the getAsBoolean() method if it exists. + - if `directive.if.emptycheck` = `false` (`true` by default), stop here and consider it true. + - 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 Collection 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. + - consider the condition is `true` + + *output* - May contain VTL. Examples (showing different operators):