Module: Crystal::BasicHtmlHelper
- Defined in:
- lib/crystal/html/view_helpers/basic_html_helper.rb
Constant Summary collapse
- BOOLEAN_ATTRIBUTES =
%w(disabled readonly multiple checked autobuffer autoplay controls loop selected hidden scoped async defer reversed ismap seemless muted required autofocus novalidate formnovalidate open).to_set
Instance Method Summary collapse
-
#authenticity_token ⇒ Object
authenticity_token.
-
#h(obj) ⇒ Object
Escape.
-
#image_tag(src, opt = {}) ⇒ Object
Assets.
-
#label_tag(name, text, options = {}) ⇒ Object
Common HTML tags.
-
#stylesheet_link_tag(*stylesheets) ⇒ Object
JavaScript & StyleSheets.
-
#tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block) ⇒ Object
Special.
Instance Method Details
#authenticity_token ⇒ Object
authenticity_token
13 |
# File 'lib/crystal/html/view_helpers/basic_html_helper.rb', line 13 def authenticity_token; workspace.request.session['authenticity_token'] end |
#h(obj) ⇒ Object
Escape
62 |
# File 'lib/crystal/html/view_helpers/basic_html_helper.rb', line 62 def h obj; obj.to_s.html_escape end |
#image_tag(src, opt = {}) ⇒ Object
Assets
29 30 31 32 |
# File 'lib/crystal/html/view_helpers/basic_html_helper.rb', line 29 def image_tag src, opt = {} opt[:src] = src tag :img, '', opt end |
#label_tag(name, text, options = {}) ⇒ Object
Common HTML tags
38 39 40 |
# File 'lib/crystal/html/view_helpers/basic_html_helper.rb', line 38 def label_tag name, text, = {} tag :label, text, .merge(:for => name) end |
#stylesheet_link_tag(*stylesheets) ⇒ Object
JavaScript & StyleSheets
19 20 21 22 23 |
# File 'lib/crystal/html/view_helpers/basic_html_helper.rb', line 19 def stylesheet_link_tag *stylesheets Array(stylesheets).collect{|ssheet| tag :link, '', :href => "#{config && config.url_root!}#{ssheet}", :media => "screen", :rel => "stylesheet", :type => "text/css" }.join("\n") end |
#tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block) ⇒ Object
Special
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/crystal/html/view_helpers/basic_html_helper.rb', line 46 def tag name, = nil, = nil, escape = true, &block if block_given? = if .is_a?(Hash) content = capture(&block) concat "<#{name}#{()}>#{content}</#{name}>" else content = "<#{name}#{()}>#{content}</#{name}>" end end |