1. nvelocity Parameters
Example:
1. Establish a macro
# Macro (test $ range $ arraylist)
...
# End
2. macro call
# Test ([-9,-1] ["favorite", "color"])
In the preceding example, you only need a # macro command that provides the name for each parameter to be passed. These parameters are separated by spaces. In the above example, # macro (test $ range $ arraylist) "test" is a macro name, and $ range $ arraylist is a parameter. Use "#" + macro name (parameter 1 parameter 2...) to call the macro.
2. nvelocity recursive call
Nesting. The simplest case is to use macro to call another macro in nvelocity.CodeThe most frequently used one in development. Recursion is a special type of nesting. It calls itself in macro in nvelocity, but this situation is not very common.
# Macro (recurs $ depth)
Enter the $ depth layer <br/>
# Set ($ depth = $ depth-1)
# If ($ depth> 0)
# Recurs ($ depth)
# End
# Set ($ depth = $ depth + 1)
Enter the $ depth layer <br/>
# End
# Recurs (3)
Execution result:
Go to Layer 3
Go to Layer 3
Go to Layer 3
Go to Layer 3
Go to Layer 3
Go to Layer 3
Note: During recursive calls, do not pass the attribute of an objectParametersRecursive call. In the preceding example, if $ depth is an object, use # recurs ($ depth. attribute), the template output is often faulty and cannot be found. Record it here and forget not to make such an error. The reason is that I think it is because of the object type. I often cannot recognize the object type when calling it (I can only understand it like this for the time being, but I have not studied it in depth ).