Module: Elpong::Rails::Helper
- Defined in:
- lib/elpong/rails/helper.rb
Instance Method Summary collapse
- #elpong_collection(name, options = {}) ⇒ Object
- #elpong_element(singular_name, options = {}) ⇒ Object
- #elpong_scheme(name_or_scheme = nil) ⇒ Object
Instance Method Details
#elpong_collection(name, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/elpong/rails/helper.rb', line 9 def elpong_collection(name, = {}) scheme = get_scheme_from_name_or_scheme([:scheme]) # options[:locals] ||= raise StandardError, 'No path or data' unless [:path] || [:data] content = [:data] || h( render(formats: [:json], template: [:path], locals: [:locals] || {}) ) attributes = { name: 'elpong-collection', content: content, scheme: scheme.name, collection: name } content_tag(:meta, nil, attributes) end |
#elpong_element(singular_name, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/elpong/rails/helper.rb', line 26 def elpong_element(singular_name, = {}) scheme = get_scheme_from_name_or_scheme([:scheme]) raise StandardError, 'No path or data' unless [:path] || [:data] content = [:data] || h( render(formats: [:json], template: [:path], locals: [:locals] || {}) ) attributes = { name: 'elpong-element', content: content, scheme: scheme.name, collection: singular_name.pluralize } [:attributes].each do |name, value| attributes[name] = value end content_tag(:meta, nil, attributes) end |
#elpong_scheme(name_or_scheme = nil) ⇒ Object
4 5 6 7 |
# File 'lib/elpong/rails/helper.rb', line 4 def elpong_scheme(name_or_scheme = nil) scheme = get_scheme_from_name_or_scheme(name_or_scheme) content_tag(:meta, nil, name: 'elpong-scheme', content: scheme.to_json, scheme: scheme.name) end |