Module: Flatrack::View::TagHelper

Includes:
ERB::Util, CaptureHelper
Included in:
Flatrack::View, LinkHelper
Defined in:
lib/flatrack/view/tag_helper.rb

Constant Summary collapse

PRE_CONTENT_STRINGS =
{
  textarea: "\n"
}
BOOLEAN_ATTRIBUTES =
%w(disabled readonly multiple checked autobuffer
autoplay controls loop selected hidden scoped
async defer reversed ismap seamless muted
required autofocus novalidate formnovalidate open
pubdate itemscope allowfullscreen default inert
sortable truespeed typemustmatch).to_set

Instance Method Summary collapse

Instance Method Details

#html_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/flatrack/view/tag_helper.rb', line 18

def html_tag(name, content_or_options_with_block = nil, options = nil,
  escape = true, &block)
  if block_given?
    if content_or_options_with_block.is_a?(Hash)
      options = content_or_options_with_block
    end
    html_tag_string(name, capture(&block), options, escape)
  else
    html_tag_string(name, content_or_options_with_block, options, escape)
  end
end

#image_tag(uri, options = {}) ⇒ Object



30
31
32
33
34
# File 'lib/flatrack/view/tag_helper.rb', line 30

def image_tag(uri, options = {})
  uri = asset_path(uri) unless uri =~ %r{^(http)?(s)?:?\/\/}
  options.merge! src: uri
  html_tag(:img, nil, options)
end

#javascript_tag(uri) ⇒ Object



36
37
38
39
# File 'lib/flatrack/view/tag_helper.rb', line 36

def javascript_tag(uri)
  uri = asset_path(uri) + '.js' if uri.is_a? Symbol
  html_tag(:script, '', src: uri, type: 'application/javascript')
end

#stylesheet_tag(uri) ⇒ Object



41
42
43
44
# File 'lib/flatrack/view/tag_helper.rb', line 41

def stylesheet_tag(uri)
  uri = asset_path(uri) + '.css' if uri.is_a? Symbol
  html_tag(:link, nil, rel: 'stylesheet', type: 'text/css', href: uri)
end