module Runcobo::Render

Direct including types

Defined in:

runcobo/actions/render.cr

Macro Summary

Instance Method Summary

Macro Detail

macro layout(filename) #

Inherited by child actions; nil disables the default layout.


[View source]
macro 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.


[View source]
macro render(template, *, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil, engine = nil) #

[View source]
macro render_jbuilder(filename, *, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil) #

Explicit engine entries retain paths relative to the template root.


[View source]
macro render_to_string(*, layout = :inherit, dir = nil, layout_dir = nil, engine = nil) #

Same conventions as render, without writing the response.


[View source]
macro render_to_string(template, *, layout = :inherit, dir = nil, layout_dir = nil, engine = nil) #

[View source]
macro render_water(filename, *, layout = :inherit, status_code = 200, dir = nil, layout_dir = nil) #

[View source]

Instance Method Detail

def render_body(body : String, *, status_code : Int32 = 200, content_type : String | Nil = nil) : HTTP::Server::Context #

Renders Body with custom Content-Type.

class RenderBody < BaseAction
  call do
    render_body "Hello World!", content_type: "text/html", status_code: 200
  end
end

[View source]
def render_empty(*, status_code : Int32 = 200, content_type : String | Nil = nil) : HTTP::Server::Context #

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.


[View source]
def render_file(path : String, *, status_code : Int32 = 200, content_type : String | Nil, filename : String | Nil = nil, disposition : String = "attachment") : HTTP::Server::Context #

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

[View source]
def render_json(value, *, status_code : Int32 = 200) : HTTP::Server::Context #

Renders a value directly without a template.


[View source]
def render_plain(text : String, *, status_code : Int32 = 200) : HTTP::Server::Context #

Renders Plain with "text/plain" Content-Type.

class RenderPlain < BaseAction
  call do
    render_plain "Hello World!", status_code: 200
  end
end

[View source]