Class: VertxWebTemplThymeleaf::ThymeleafTemplateEngine
- Inherits:
-
VertxWebCommon::TemplateEngine
show all
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb
Overview
A template engine that uses the Thymeleaf library.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Class Method Details
+ (Boolean) accept?(obj)
20
21
22
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 20
def @@j_api_type.accept?(obj)
obj.class == ThymeleafTemplateEngine
end
|
Create a template engine using defaults
62
63
64
65
66
67
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 62
def self.create(vertx=nil)
if vertx.class.method_defined?(:j_del) && !block_given?
return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebTemplThymeleaf::ThymeleafTemplateEngine.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxWebTemplThymeleaf::ThymeleafTemplateEngine)
end
raise ArgumentError, "Invalid arguments when calling create(#{vertx})"
end
|
+ (Object) DEFAULT_TEMPLATE_MODE
78
79
80
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 78
def self.DEFAULT_TEMPLATE_MODE
Java::IoVertxExtWebTemplThymeleaf::ThymeleafTemplateEngine.DEFAULT_TEMPLATE_MODE.name.intern
end
|
+ (Object) j_api_type
29
30
31
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 29
def self.j_api_type
@@j_api_type
end
|
+ (Object) j_class
32
33
34
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 32
def self.j_class
Java::IoVertxExtWebTemplThymeleaf::ThymeleafTemplateEngine.java_class
end
|
+ (Object) unwrap(obj)
26
27
28
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 26
def @@j_api_type.unwrap(obj)
obj.j_del
end
|
+ (Object) wrap(obj)
23
24
25
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 23
def @@j_api_type.wrap(obj)
ThymeleafTemplateEngine.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.
53
54
55
56
57
58
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 53
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".
44
45
46
47
48
49
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 44
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_mode(mode = nil)
Set the mode for the engine
71
72
73
74
75
76
77
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-templ-thymeleaf/thymeleaf_template_engine.rb', line 71
def set_mode(mode=nil)
if mode.class == Symbol && !block_given?
@j_del.java_method(:setMode, [Java::OrgThymeleafTemplatemode::TemplateMode.java_class]).call(Java::OrgThymeleafTemplatemode::TemplateMode.valueOf(mode.to_s))
return self
end
raise ArgumentError, "Invalid arguments when calling set_mode(#{mode})"
end
|