Module: Rad::Html::BasicHtmlHelper
- Defined in:
- lib/rad/html/_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
-
#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
#h(obj) ⇒ Object
Escape
51 |
# File 'lib/rad/html/_helpers/basic_html_helper.rb', line 51 def h obj; obj.to_s.html_escape end |
#image_tag(src, opt = {}) ⇒ Object
Assets
22 23 24 25 |
# File 'lib/rad/html/_helpers/basic_html_helper.rb', line 22 def image_tag src, opt = {} opt[:src] = src tag :img, '', opt end |
#label_tag(name, text, options = {}) ⇒ Object
Common HTML tags
31 32 33 |
# File 'lib/rad/html/_helpers/basic_html_helper.rb', line 31 def label_tag name, text, = {} tag :label, text, .merge(for: name) end |
#stylesheet_link_tag(*stylesheets) ⇒ Object
JavaScript & StyleSheets
12 13 14 15 16 |
# File 'lib/rad/html/_helpers/basic_html_helper.rb', line 12 def stylesheet_link_tag *stylesheets stylesheets.collect{|ssheet| tag :link, '', href: "#{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
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rad/html/_helpers/basic_html_helper.rb', line 39 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 |