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
- #abbr_map ⇒ Object
- #abbr_tag(key, options = {}) ⇒ Object
- #keyboard_shortcut_map ⇒ Object
-
#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>.
-
#keyboard_tag(key, options = {}) ⇒ Object
The
kbd
element typically represents keyboard input, though it may also represent other input, such as voice commands. - #meter_tag ⇒ Object
- #progress_tag ⇒ Object
- #unicode_entity(key) ⇒ Object
- #unicode_glyph(key) ⇒ Object
- #unicode_map ⇒ Object
Instance Method Details
#abbr_map ⇒ Object
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, = {}) [:title] ||= key value = abbr_map[key] capture_haml { haml_tag :abbr, value, } end |
#keyboard_shortcut_map ⇒ Object
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) = args. capture_haml do haml_tag :kbd, 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, = {}) [:title] ||= key value = keyboard_shortcut_map[key] capture_haml { haml_tag :kbd, value, } end |
#meter_tag ⇒ Object
65 66 67 |
# File 'lib/storefront/helpers/tag_helper.rb', line 65 def meter_tag end |
#progress_tag ⇒ Object
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_map ⇒ Object
81 82 83 |
# File 'lib/storefront/helpers/tag_helper.rb', line 81 def unicode_map @unicode_map ||= t(:unicode) end |