Author: cbrisson Date: Fri Jan 24 09:39:13 2020 New Revision: 1873094 URL: http://svn.apache.org/viewvc?rev=1873094&view=rev Log: [site/engine] Fix doc about velocimacros argument passing convention for 2.x
Modified: velocity/site/cms/trunk/content/engine/2.0/user-guide.mdtext velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext velocity/site/cms/trunk/content/engine/2.2/user-guide.mdtext velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext 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=1873094&r1=1873093&r2=1873094&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 Fri Jan 24 09:39:13 2020 @@ -817,7 +817,7 @@ Velocimacros can take as arguments any o + boolean value true + boolean value false -When passing references as arguments to Velocimacros, please note that references are passed 'by name'. This means that their value is 'generated' at each use inside the Velocimacro. This feature allows you to pass references with method calls and have the method called at each use. For example, when calling the following Velocimacro as shown +Since 2.0, Velocimacros arguments are passed by value (or, more precisely, the result of their evaluation is passed by reference). This means that they are evaluated only once, even when used several times inside the macro. It means that in the following example: :::velocity #macro( callme $a ) @@ -826,16 +826,7 @@ When passing references as arguments to #callme( $foo.bar() ) -results in the method bar() of the reference $foo being called 3 times. - -At first glance, this feature appears surprising, but when you take into consideration the original motivation behind Velocimacros -- to eliminate cut'n'paste duplication of commonly used VTL -- it makes sense. It allows you to do things like pass stateful objects, such as an object that generates colors in a repeating sequence for coloring table rows, into the Velocimacro. - -If you need to circumvent this feature, you can always just get the value from the method as a new reference and pass that : - - :::velocity - #set( $myval = $foo.bar() ) - #callme( $myval ) - +the method bar() of the reference $foo is only called once. #### Velocimacro Properties 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=1873094&r1=1873093&r2=1873094&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 Jan 24 09:39:13 2020 @@ -828,7 +828,7 @@ Velocimacros can take as arguments any o + boolean value true + boolean value false -When passing references as arguments to Velocimacros, please note that references are passed 'by name'. This means that their value is 'generated' at each use inside the Velocimacro. This feature allows you to pass references with method calls and have the method called at each use. For example, when calling the following Velocimacro as shown +Since 2.0, Velocimacros arguments are passed by value (or, more precisely, the result of their evaluation is passed by reference). This means that they are evaluated only once, even when used several times inside the macro. It means that in the following example: :::velocity #macro( callme $a ) @@ -837,16 +837,7 @@ When passing references as arguments to #callme( $foo.bar() ) -results in the method bar() of the reference $foo being called 3 times. - -At first glance, this feature appears surprising, but when you take into consideration the original motivation behind Velocimacros -- to eliminate cut'n'paste duplication of commonly used VTL -- it makes sense. It allows you to do things like pass stateful objects, such as an object that generates colors in a repeating sequence for coloring table rows, into the Velocimacro. - -If you need to circumvent this feature, you can always just get the value from the method as a new reference and pass that : - - :::velocity - #set( $myval = $foo.bar() ) - #callme( $myval ) - +the method bar() of the reference $foo is only called once. #### Velocimacro Properties Modified: velocity/site/cms/trunk/content/engine/2.2/user-guide.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.2/user-guide.mdtext?rev=1873094&r1=1873093&r2=1873094&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/2.2/user-guide.mdtext (original) +++ velocity/site/cms/trunk/content/engine/2.2/user-guide.mdtext Fri Jan 24 09:39:13 2020 @@ -828,7 +828,7 @@ Velocimacros can take as arguments any o + boolean value true + boolean value false -When passing references as arguments to Velocimacros, please note that references are passed 'by name'. This means that their value is 'generated' at each use inside the Velocimacro. This feature allows you to pass references with method calls and have the method called at each use. For example, when calling the following Velocimacro as shown +Since 2.0, Velocimacros arguments are passed by value (or, more precisely, the result of their evaluation is passed by reference). This means that they are evaluated only once, even when used several times inside the macro. It means that in the following example: :::velocity #macro( callme $a ) @@ -837,16 +837,7 @@ When passing references as arguments to #callme( $foo.bar() ) -results in the method bar() of the reference $foo being called 3 times. - -At first glance, this feature appears surprising, but when you take into consideration the original motivation behind Velocimacros -- to eliminate cut'n'paste duplication of commonly used VTL -- it makes sense. It allows you to do things like pass stateful objects, such as an object that generates colors in a repeating sequence for coloring table rows, into the Velocimacro. - -If you need to circumvent this feature, you can always just get the value from the method as a new reference and pass that : - - :::velocity - #set( $myval = $foo.bar() ) - #callme( $myval ) - +the method bar() of the reference $foo is only called once. #### Velocimacro Properties 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=1873094&r1=1873093&r2=1873094&view=diff ============================================================================== --- velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext (original) +++ velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext Fri Jan 24 09:39:13 2020 @@ -828,7 +828,7 @@ Velocimacros can take as arguments any o + boolean value true + boolean value false -When passing references as arguments to Velocimacros, please note that references are passed 'by name'. This means that their value is 'generated' at each use inside the Velocimacro. This feature allows you to pass references with method calls and have the method called at each use. For example, when calling the following Velocimacro as shown +Since 2.0, Velocimacros arguments are passed by value (or, more precisely, the result of their evaluation is passed by reference). This means that they are evaluated only once, even when used several times inside the macro. It means that in the following example: :::velocity #macro( callme $a ) @@ -837,16 +837,7 @@ When passing references as arguments to #callme( $foo.bar() ) -results in the method bar() of the reference $foo being called 3 times. - -At first glance, this feature appears surprising, but when you take into consideration the original motivation behind Velocimacros -- to eliminate cut'n'paste duplication of commonly used VTL -- it makes sense. It allows you to do things like pass stateful objects, such as an object that generates colors in a repeating sequence for coloring table rows, into the Velocimacro. - -If you need to circumvent this feature, you can always just get the value from the method as a new reference and pass that : - - :::velocity - #set( $myval = $foo.bar() ) - #callme( $myval ) - +the method bar() of the reference $foo is only called once. #### Velocimacro Properties