class Marten::Handlers::RecordList
Overview
Handler allowing to list model records.
This base handler can be used to easily expose a list of model records:
class MyHandler < Marten::Handlers::RecordList
template_name "my_template"
model Post
end
Optionally, it is possible to configure that records should be paginated:
class MyHandler < Marten::Handlers::RecordList
template_name "my_template"
model Post
page_size 12
end
When records are paginated, a Marten::DB::Query::Page
will be exposed in the template context (instead of the
raw query set).
Included Modules
Extended Modules
Defined in:
marten/handlers/record_list.crClass Method Summary
-
.list_context_name(name : String | Symbol)
Allows to configure the name to use to include the list of records into the template context.
-
.list_context_name : String
Returns the name to use to include the record list into the template context (defaults to
records
). -
.ordering : Array(String) | Nil
Returns the array of fields to use to order the records.
-
.page_number_param : String
Returns the name of the page number parameter.
-
.page_size : Int32 | Nil
Returns the page size to use if records should be paginated.
Instance methods inherited from module Marten::Handlers::RecordListing
model
model,
paginate_queryset
paginate_queryset,
queryset
queryset
Macros inherited from module Marten::Handlers::RecordListing
model(model_klass)
model,
queryset(queryset)
queryset
Instance methods inherited from class Marten::Handlers::Template
get
get
Class methods inherited from class Marten::Handlers::Template
content_type : String | Nil
content_type,
template_name : String | Nil
template_name
Instance methods inherited from module Marten::Handlers::Rendering
content_type : String
content_type,
render_to_response(context : Hash | NamedTuple | Nil | Marten::Template::Context = nil, status : ::HTTP::Status | Int32 = 200)
render_to_response,
template_name : String
template_name
Instance methods inherited from class Marten::Handlers::Base
context
context,
delete
delete,
dispatch : Marten::HTTP::Response
dispatch,
get
get,
head(status : ::HTTP::Status | Int32) : HTTP::Responsehead head, json(raw_json : String, status : ::HTTP::Status | Int32 = 200)
json(serializable, status : ::HTTP::Status | Int32 = 200) json, options options, params : Marten::Routing::MatchParameters params, patch patch, post post, put put, redirect(url : String, permanent = false) redirect, render(template_name : String, context : Hash | NamedTuple | Nil | Marten::Template::Context = nil, content_type = HTTP::Response::DEFAULT_CONTENT_TYPE, status : ::HTTP::Status | Int32 = 200) render, request : Marten::HTTP::Request request, respond(streamed_content : Iterator(String), content_type = HTTP::Response::DEFAULT_CONTENT_TYPE, status : ::HTTP::Status | Int32 = 200)
respond(content = "", content_type = HTTP::Response::DEFAULT_CONTENT_TYPE, status : ::HTTP::Status | Int32 = 200) respond, response : Marten::HTTP::Response? response, response! response!, reverse(*args, **options)
reverse(*args, **options, &) reverse, trace trace, url(name : String | Symbol, **kwargs) : String url
Constructor methods inherited from class Marten::Handlers::Base
new(request : HTTP::Request, params : Routing::MatchParameters)new(request : HTTP::Request, **kwargs) new
Class methods inherited from class Marten::Handlers::Base
content_security_policy_block
content_security_policy_block,
http_method_nameshttp_method_names(*method_names : String | Symbol) http_method_names
Instance methods inherited from module Marten::Handlers::Session
session(*args, **options)session(*args, **options, &) session
Instance methods inherited from module Marten::Handlers::RequestForgeryProtection
get_csrf_token
get_csrf_token,
referer_trusted?
referer_trusted?
Instance methods inherited from module Marten::Handlers::Flash
flash(*args, **options)flash(*args, **options, &) flash
Instance methods inherited from module Marten::Handlers::Cookies
cookies(*args, **options)cookies(*args, **options, &) cookies
Macros inherited from module Marten::Handlers::Callbacks
after_dispatch(*names)
after_dispatch,
before_dispatch(*names)
before_dispatch,
before_render(*names)
before_render
Macros inherited from module Marten::Core::DebugModeLoggable
debug_mode_debug_log(message)
debug_mode_debug_log,
debug_mode_info_log(message)
debug_mode_info_log
Class Method Detail
Allows to configure the name to use to include the list of records into the template context.
Returns the name to use to include the record list into the template context (defaults to records
).