module ViewModel::Helpers
Overview
Includes all UI helper methods like tag helpers, partial definition and rendering.
NOTE if you would like to make several level of module inclusion you should include this module in each module in a hierarchy.
Included Modules
Direct including types
Defined in:
view_model/helpers.crMacro Summary
-
build_form(name, url, html_options = {} of String => String, method = :post, io_variable = __kilt_io__)
Creates form builder and yields it to the block.
-
def_partial(name, *args)
Defines method for rendering partial.
-
link_to(path, text = "", html_options = {} of String => String, method = nil, io_variable = __kilt_io__)
Creates a link tag of the given text using URL given in the path argument.
-
render_partial(name, *args)
Renders partial with name name and passes args to it.
Instance methods inherited from module ViewModel::FormTags
checkbox_tag(name : String | Symbol, value = nil, options = SHash.new)checkbox_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) checkbox_tag, content_tag(io : String::Builder, tag, html_options = SHash.new)
content_tag(tag, html_options : Hash = {} of String => String)
content_tag(io : String::Builder, tag, html_options = SHash.new, &block)
content_tag(tag, html_options : Hash = {} of String => String, &block) content_tag, date_tag(name : String | Symbol, value = nil, options = SHash.new)
date_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) date_tag, email_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new)
email_tag(name : String | Symbol, value = nil, options = SHash.new) email_tag, file_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new)
file_tag(name : String | Symbol, value = nil, options = SHash.new) file_tag, hidden_tag(name : String | Symbol, value = nil, options = SHash.new)
hidden_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) hidden_tag, label_tag(io : String::Builder, for : Symbol | String? = nil, html_options = SHash.new, &block)
label_tag(io : String::Builder, text, for : Symbol | String? = nil, html_options = SHash.new)
label_tag(text, for : Symbol | String? = nil, html_options = {} of String => String)
label_tag(for : Symbol | String? = nil, html_options = SHash.new, &block) label_tag, number_tag(name : String | Symbol, value = nil, options = SHash.new)
number_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) number_tag, password_tag(name : String | Symbol, value = nil, options = SHash.new)
password_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) password_tag, radio_tag(name : String | Symbol, value = nil, options = SHash.new)
radio_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) radio_tag, select_tag(io : String::Builder, name : String | Symbol, options : Array(Array), value = nil, html_options = SHash.new)
select_tag(name, options : Array(Array), value = nil, html_options = {} of String => String) select_tag, submit_tag(name : String | Symbol, value = nil, options = SHash.new)
submit_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) submit_tag, text_area_tag(io : String::Builder, name, text = "", html_options = {} of String => String)
text_area_tag(name, text = "", html_options = {} of String => String) text_area_tag, text_tag(name : String | Symbol, value = nil, options = SHash.new)
text_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) text_tag, time_tag(name : String | Symbol, value = nil, options = SHash.new)
time_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) time_tag
Macro Detail
Creates form builder and yields it to the block.
It is important not to print macro invocation to the general builder.
- build_form :session, { "class" => "form new-form" } do |f|
p
- f.label :email, "Email"
- f.email_field :email
p
- f.label :password, "Password"
- f.password_field :password
Defines method for rendering partial.
module Partials
include ViewModel::Helpers
def_partial :without_argument
def_partial :with, argument
end
Creates a link tag of the given text using URL given in the path argument.
You can pass a block instead of text
- link_to "/users/2", "First Last Name", { "class" => "btn btn-small" }
- link_to "/users/2", "delete", method: :delete
- link_to "/users/2" do
span Open
method option allows to make a DELETE
request. Also to achieve this you should include js script
located in the assets
directory.