Class: Gretel::Renderer::Base

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

Direct Known Subclasses

NonSemanticRenderer, SemanticRenderer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, options) ⇒ Base

Returns a new instance of Base.



230
231
232
233
# File 'lib/gretel/renderer.rb', line 230

def initialize(context, options)
  @context = context
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

Proxy to view context.



284
285
286
# File 'lib/gretel/renderer.rb', line 284

def method_missing(method, *args, &block)
  context.send(method, *args, &block)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



228
229
230
# File 'lib/gretel/renderer.rb', line 228

def context
  @context
end

#optionsObject (readonly)

Returns the value of attribute options.



228
229
230
# File 'lib/gretel/renderer.rb', line 228

def options
  @options
end

Instance Method Details

#render_container(html) ⇒ Object



248
249
# File 'lib/gretel/renderer.rb', line 248

def render_container(html)
end

#render_current_fragment(link, position) ⇒ Object



239
240
241
242
243
# File 'lib/gretel/renderer.rb', line 239

def render_current_fragment(link, position)
  url = options[:link_current] ? link.url : nil
  opts = fragment_options.merge(class: options[:current_class], current_link: link.url, aria_current: options[:aria_current])
  render_fragment_tag(fragment_tag, link.text, url, position, **opts)
end

#render_fragment(link, position) ⇒ Object



235
236
237
# File 'lib/gretel/renderer.rb', line 235

def render_fragment(link, position)
  render_fragment_tag(fragment_tag, link.text, link.url, position, **fragment_options)
end

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



245
246
# File 'lib/gretel/renderer.rb', line 245

def render_fragment_tag(fragment_tag, text, url, position, options = {})
end

#render_posttextObject



257
258
259
260
261
# File 'lib/gretel/renderer.rb', line 257

def render_posttext
  if options[:posttext].present?
    (:span, options[:posttext], class: options[:posttext_class])
  end
end

#render_pretextObject



251
252
253
254
255
# File 'lib/gretel/renderer.rb', line 251

def render_pretext
  if options[:pretext].present?
    (:span, options[:pretext], class: options[:pretext_class])
  end
end