Module: Roda::RodaPlugins::Phlex
- Defined in:
- lib/roda/plugins/phlex_render.rb
Overview
The phlex plugin allows match blocks to return Phlex::HTML objects, which are automatically rendered and used as the response body.
Without the plugin:
r.is "play" do
View::Layout::Main.new(
title: "Play",
body: View::Play
).call
end
With the plugin:
plugin :phlex
r.is "play" do
View::Layout::Main.new(
title: "Play",
body: View::Play
)
end
By default, Phlex::HTML objects are rendered using #call and the response Content-Type is set to text/html; charset=utf-8.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.configure(app, opts = OPTS) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/roda/plugins/phlex_render.rb', line 36 def self.configure(app, opts = OPTS) app.opts[:phlex_result_content_type] = opts[:content_type] || "text/html; charset=utf-8" app.opts[:custom_block_results][::Phlex::HTML] = :handle_phlex_block_result end |
.load_dependencies(app, opts = OPTS) ⇒ Object
32 33 34 |
# File 'lib/roda/plugins/phlex_render.rb', line 32 def self.load_dependencies(app, opts = OPTS) app.plugin :custom_block_results end |