Class: Gretel::Renderer::SemanticRenderer

Inherits:
Base
  • Object
show all
Defined in:
lib/gretel/renderer.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #render_current_fragment, #render_fragment, #render_posttext, #render_pretext

Constructor Details

This class inherits a constructor from Gretel::Renderer::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Gretel::Renderer::Base

Instance Method Details

#render_container(html) ⇒ Object



331
332
333
# File 'lib/gretel/renderer.rb', line 331

def render_container(html)
  (options[:container_tag], html, id: options[:id], class: options[:class], itemscope: "", itemtype: "https://schema.org/BreadcrumbList")
end

#render_fragment_tag(fragment_tag, text, url, position, options = {}) ⇒ Object



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/gretel/renderer.rb', line 314

def render_fragment_tag(fragment_tag, text, url, position, options = {})
  fragment_class = join_classes(options[:fragment_class], options[:class])
  fragment_tag = fragment_tag || 'span'
  text = (:span, text, itemprop: "name")

  aria_current = options[:aria_current]
  if url.present?
    text = breadcrumb_link_to(text, url, itemprop: "item", "aria-current": aria_current, class: options[:link_class], data: options[:link_data])
    aria_current = nil
  elsif options[:current_link].present?
    text = text + tag(:link, itemprop: "item", href: options[:current_link])
  end

  text = text + tag(:meta, itemprop: "position", content: "#{position}")
  (fragment_tag.to_sym, text, class: fragment_class, itemprop: "itemListElement", itemscope: "", itemtype: "https://schema.org/ListItem", "aria-current": aria_current, data: options[:link_data])
end