Package org.takes.rs

Class RsVelocity

  • All Implemented Interfaces:
    Body, Head, Response

    public final class RsVelocity
    extends RsWrap
    Response that converts Velocity template to text.

    This response implementation is rendering a page from Apache Velocity template. Here is how you can use it:

    public final class TkHelp implements Take {
       @Override
       public Response act(final Request req) {
         return new RsHTML(
           new RsVelocity(
             this.getClass().getResource("help.html.vm"),
             new RsVelocity.Pair("name", "Jeffrey")
           )
         );
       }
     }

    The class is immutable and thread-safe.

    Since:
    0.1
    • Constructor Detail

      • RsVelocity

        public RsVelocity​(CharSequence template,
                          RsVelocity.Pair... params)
        Ctor.
        Parameters:
        template - Template
        params - List of params
        Since:
        0.11
      • RsVelocity

        public RsVelocity​(URL template,
                          RsVelocity.Pair... params)
                   throws IOException
        Ctor.
        Parameters:
        template - Template
        params - List of params
        Throws:
        IOException - If fails
        Since:
        0.11
      • RsVelocity

        public RsVelocity​(InputStream template,
                          RsVelocity.Pair... params)
        Ctor.
        Parameters:
        template - Template
        params - Entries
      • RsVelocity

        public RsVelocity​(String folder,
                          InputStream template,
                          Map<CharSequence,​Object> params)
        Ctor.
        Parameters:
        folder - Template folder
        template - Template
        params - Map of params
      • RsVelocity

        public RsVelocity​(String folder,
                          InputStream template,
                          org.cactoos.Scalar<Map<String,​Object>> params)
        Ctor.
        Parameters:
        folder - Template folder
        template - Template
        params - Map of params