Module: Storefront::Helpers::TagHelper

Defined in:
lib/storefront/helpers/tag_helper.rb

Overview

This module is a replacement for some of the common core Rails tag helper methods. It is not included by default.

It adds a few missing features to some of the tags, so you can configure them globally. It also runs them through haml instead, so the attribute string sequence is normalized.

Instance Method Summary collapse

Instance Method Details

#abbr_mapObject



61
62
63
# File 'lib/storefront/helpers/tag_helper.rb', line 61

def abbr_map
  @abbr_map ||= t(:abbr)
end

#abbr_tag(key, options = {}) ⇒ Object



55
56
57
58
59
# File 'lib/storefront/helpers/tag_helper.rb', line 55

def abbr_tag(key, options = {})
  options[:title] ||= key
  value = abbr_map[key]
  capture_haml { haml_tag :abbr, value, options }
end

#keyboard_shortcut_mapObject



35
36
37
# File 'lib/storefront/helpers/tag_helper.rb', line 35

def keyboard_shortcut_map
  @keyboard_shortcut_map ||= t(:keyboard)
end

#keyboard_shortcut_tag(*args) ⇒ Object

keyboard_shortcut_tag(:command, :shift, :s, :title => :save)

<kbd title='save'>
  <kbd title='command'>⌘</kbd><kbd title='shift'> ⇧</kbd><kbd>s</kbd>
</kbd>


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/storefront/helpers/tag_helper.rb', line 43

def keyboard_shortcut_tag(*args)
  options = args.extract_options!
  
  capture_haml do
    haml_tag :kbd, options do
      args.each do |key|
        keyboard_tag(key)
      end
    end
  end
end

#keyboard_tag(key, options = {}) ⇒ Object

The kbd element typically represents keyboard input, though it may also represent other input, such as voice commands.



29
30
31
32
33
# File 'lib/storefront/helpers/tag_helper.rb', line 29

def keyboard_tag(key, options = {})
  options[:title] ||= key
  value = keyboard_shortcut_map[key]
  capture_haml { haml_tag :kbd, value, options }
end

#meter_tagObject



65
66
67
# File 'lib/storefront/helpers/tag_helper.rb', line 65

def meter_tag
  
end

#progress_tagObject



69
70
71
# File 'lib/storefront/helpers/tag_helper.rb', line 69

def progress_tag
  
end

#unicode_entity(key) ⇒ Object



73
74
75
# File 'lib/storefront/helpers/tag_helper.rb', line 73

def unicode_entity(key)
  unicode_map[key][:code]
end

#unicode_glyph(key) ⇒ Object



77
78
79
# File 'lib/storefront/helpers/tag_helper.rb', line 77

def unicode_glyph(key)
  unicode_map[key][:glypy]
end

#unicode_mapObject



81
82
83
# File 'lib/storefront/helpers/tag_helper.rb', line 81

def unicode_map
  @unicode_map ||= t(:unicode)
end