module
Runcobo::Render
Direct including types
Defined in:
runcobo/actions/render.crMacro Summary
-
layout(filename)
Inherited by child actions; nil disables the default layout.
-
render(*, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil, engine = nil)
Render the current action or a literal template name using the configured engine.
- render(template, *, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil, engine = nil)
-
render_jbuilder(filename, *, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil)
Explicit engine entries retain paths relative to the template root.
-
render_to_string(*, layout = :inherit, dir = nil, layout_dir = nil, engine = nil)
Same conventions as render, without writing the response.
- render_to_string(template, *, layout = :inherit, dir = nil, layout_dir = nil, engine = nil)
- render_water(filename, *, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil)
Instance Method Summary
-
#render_body(body : String, *, status_code : Int32 = 200, content_type : String | Nil = nil) : HTTP::Server::Context
Renders Body with custom Content-Type.
-
#render_empty(*, status_code : Int32 = 200, content_type : String | Nil = nil) : HTTP::Server::Context
Explicitly send an empty response.
-
#render_file(path : String, *, status_code : Int32 = 200, content_type : String | Nil, filename : String | Nil = nil, disposition : String = "attachment") : HTTP::Server::Context
Renders File.
-
#render_json(value, *, status_code : Int32 = 200) : HTTP::Server::Context
Renders a value directly without a template.
-
#render_plain(text : String, *, status_code : Int32 = 200) : HTTP::Server::Context
Renders Plain with "text/plain" Content-Type.
Macro Detail
Render the current action or a literal template name using the configured engine.
Explicit engine entries retain paths relative to the template root.
Same conventions as render, without writing the response.
Instance Method Detail
Renders Body with custom Content-Type.
class RenderBody < BaseAction
call do
render_body "Hello World!", content_type: "text/html", status_code: 200
end
end
Explicitly send an empty response. The action chooses when to use this; other renderers do not suppress output based on the request method or status.
Renders File.
class RenderFile < BaseAction
call do
render_file "public/robot.txt", status_code: 200, content_type: "text/plain", filename: "robot", disposition: "inline"
end
end
Renders a value directly without a template.
Renders Plain with "text/plain" Content-Type.
class RenderPlain < BaseAction
call do
render_plain "Hello World!", status_code: 200
end
end