Class List Method List File List

# Class: VertxWeb::TemplateEngine

Inherits:
  Object
  - Object
  - VertxWeb::TemplateEngine
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb

## Overview

A template engine uses a specific template and the data in a routing context to render a resource into a buffer.

Concrete implementations exist for several well-known template engines.

## Direct Known Subclasses

FreeMarkerTemplateEngine, HandlebarsTemplateEngine, JadeTemplateEngine, MVELTemplateEngine, PebbleTemplateEngine, ThymeleafTemplateEngine

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) render(context = nil, templateFileName = nil) { ... }
  Render.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    21
    22
    23
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb', line 21

    def @@j_api_type.accept?(obj)
      obj.class == TemplateEngine
    end

### + (`Object`) j_api_type

    30
    31
    32
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb', line 30

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    33
    34
    35
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb', line 33

    def self.j_class
      Java::IoVertxExtWebTempl::TemplateEngine.java_class
    end

### + (`Object`) unwrap(obj)

    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb', line 27

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    24
    25
    26
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb', line 24

    def @@j_api_type.wrap(obj)
      TemplateEngine.new(obj)
    end

## Instance Method Details

### - (`void`) render(context = nil, templateFileName = nil) { ... }

This method returns an undefined value.

Render

Parameters:

- context (`::VertxWeb::RoutingContext`) (defaults to: `nil`) —
  the routing context
- templateFileName (`String`) (defaults to: `nil`) —
  the template file name to use

Yields:

- the handler that will be called with a result containing the buffer or a failure.

Raises:

- (`ArgumentError`)

    41
    42
    43
    44
    45
    46
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_engine.rb', line 41

    def render(context=nil,templateFileName=nil)
      if context.class.method_defined?(:j_del) && templateFileName.class == String && block_given?
        return @j_del.java_method(:render, [Java::IoVertxExtWeb::RoutingContext.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(context.j_del,templateFileName,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Buffer) : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling render(#{context},#{templateFileName})"
    end