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.



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

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.



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

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#render_container(html) ⇒ Object



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

def render_container(html)
end

#render_current_fragment(link, position) ⇒ Object



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

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



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

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



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

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

#render_posttextObject



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

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

#render_pretextObject



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

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