Annotation Interface JStacheLambda

Tag a method to be used as a mustache lambda section. Lambda sections look something like:
Where in the above example a lambda is named "lambda" and optionally has access to the object called "context" and the raw body passed to the lambda is "body".

JStachio lambdas just like normal method calls do not have to be directly enclosed on the context objects but can be on implemented interfaces or inherited and thus models can be "mixed in" with interfaces to achieve sharing of lambdas. However there is currently no support for static methods to be used as lambdas.

JStachio lambdas work in basically two modes for parameters:

  • Context aware: The default. The top of the stack is passed if an argument is present and is not annotated with JStacheLambda.Raw.
  • Raw: If a string parameter is annoated with JStacheLambda.Raw it will be passed the contents of the lambda section call. While this mode is the default for the spec it is not for JStachio!. n.b. the contents may not be valid mustache as the spec does not define that it has to be.

Similarly JStachio works in two modes for return types:

  • Model: The default. The returned model forms its own isolated context stack and the contents of the lambda section call are used as an inline template and rendered against the returned context.
  • Raw: If the return type is a String and the method is annotated with JStacheLambda.Raw the contents of the string are directly written unescaped.

Due to the static nature of JStachio, JStachio does not support returning dynamic templates which is the optional lambda spec default if a String is returned.

JStachio is very similar to the JMustache model and does not have an analog in JStachio currently does not support returning closures of Function<String,String> like but models can be like Supplier<String> for that use case.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    static @interface 
    Tag a method return type of String or parameter of String to be used as a raw unprocessed string.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    The logical name of the lambda.
  • Element Details

    • name

      The logical name of the lambda. If blank the method name will be used.
      lambda name