Class: VertxWebTemplRocker::RockerTemplateEngine

Inherits:
VertxWebCommon::TemplateEngine show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb

Overview

A template engine that uses the Rocker library.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


19
20
21
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 19

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

+ (::VertxWebTemplRocker::RockerTemplateEngine) create

Returns the engine

Returns:

Raises:

  • (ArgumentError)


59
60
61
62
63
64
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 59

def self.create
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebTemplRocker::RockerTemplateEngine.java_method(:create, []).call(),::VertxWebTemplRocker::RockerTemplateEngine)
  end
  raise ArgumentError, "Invalid arguments when calling create()"
end

+ (Object) DEFAULT_MAX_CACHE_SIZE

Default max number of templates to cache


86
87
88
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 86

def self.DEFAULT_MAX_CACHE_SIZE
  Java::IoVertxExtWebTemplRocker::RockerTemplateEngine.DEFAULT_MAX_CACHE_SIZE
end

+ (Object) DEFAULT_TEMPLATE_EXTENSION

Default template extension


90
91
92
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 90

def self.DEFAULT_TEMPLATE_EXTENSION
  Java::IoVertxExtWebTemplRocker::RockerTemplateEngine.DEFAULT_TEMPLATE_EXTENSION
end

+ (Object) j_api_type



28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 28

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 31

def self.j_class
  Java::IoVertxExtWebTemplRocker::RockerTemplateEngine.java_class
end

+ (Object) unwrap(obj)



25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 25

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

+ (Object) wrap(obj)



22
23
24
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 22

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

Instance Method Details

- (true, false) caching_enabled?

Returns true if the template template caches template files. If false, then template files are freshly loaded each time they are used.

Returns:

  • (true, false)
    True if template files are cached; otherwise, false.

Raises:

  • (ArgumentError)


52
53
54
55
56
57
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 52

def caching_enabled?
  if !block_given?
    return @j_del.java_method(:isCachingEnabled, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling caching_enabled?()"
end

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

This method returns an undefined value.

Render the template. Template engines that support partials/fragments should extract the template base path from the template filename up to the last file separator. Some engines support localization, for these engines, there is a predefined key "lang" to specify the language to be used in the localization, the format should follow the standard locale formats e.g.: "en-gb", "pt-br", "en".

Parameters:

  • context (Hash{String => Object}) (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)


43
44
45
46
47
48
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 43

def render(context=nil,templateFileName=nil)
  if context.class == Hash && templateFileName.class == String && block_given?
    return @j_del.java_method(:render, [Java::IoVertxCoreJson::JsonObject.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(context),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

- (self) set_extension(extension = nil)

Set the extension for the engine

Parameters:

  • extension (String) (defaults to: nil)
    the extension

Returns:

  • (self)

Raises:

  • (ArgumentError)


68
69
70
71
72
73
74
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 68

def set_extension(extension=nil)
  if extension.class == String && !block_given?
    @j_del.java_method(:setExtension, [Java::java.lang.String.java_class]).call(extension)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_extension(#{extension})"
end

- (self) set_max_cache_size(maxCacheSize = nil)

Set the max cache size for the engine

Parameters:

  • maxCacheSize (Fixnum) (defaults to: nil)
    the maxCacheSize

Returns:

  • (self)

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-rocker/rocker_template_engine.rb', line 78

def set_max_cache_size(maxCacheSize=nil)
  if maxCacheSize.class == Fixnum && !block_given?
    @j_del.java_method(:setMaxCacheSize, [Java::int.java_class]).call(maxCacheSize)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_max_cache_size(#{maxCacheSize})"
end