Class DirectiveNode.MacroCallNode

  • Enclosing class:
    DirectiveNode

    static class DirectiveNode.MacroCallNode
    extends DirectiveNode
    A node in the parse tree representing a macro call. If the template contains a definition like #macro (mymacro $x $y) ... #end, then a call of that macro looks like #mymacro (xvalue yvalue). The call is represented by an instance of this class. The definition itself does not appear in the parse tree.

    Evaluating a macro involves temporarily setting the parameter variables ($x $y in the example) to thunks representing the argument expressions, evaluating the macro body, and restoring any previous values that the parameter variables had.

    • Field Detail

      • name

        private final java.lang.String name
      • thunks

        private final com.google.common.collect.ImmutableList<Node> thunks
      • macro

        private Macro macro
    • Constructor Detail

      • MacroCallNode

        MacroCallNode​(java.lang.String resourceName,
                      int lineNumber,
                      java.lang.String name,
                      com.google.common.collect.ImmutableList<Node> argumentNodes)
    • Method Detail

      • name

        java.lang.String name()
      • argumentCount

        int argumentCount()
      • setMacro

        void setMacro​(Macro macro)
      • evaluate

        java.lang.Object evaluate​(EvaluationContext context)
        Description copied from class: Node
        Returns the result of evaluating this node in the given context. This result may be used as part of a further operation, for example evaluating 2 + 3 to 5 in order to set $x to 5 in #set ($x = 2 + 3). Or it may be used directly as part of the template output, for example evaluating replacing name by Fred in My name is $name..
        Specified by:
        evaluate in class Node