Class: Cloudpress::Renderers::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudpress/renderers/tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, tags) ⇒ Tags

Returns a new instance of Tags.



7
8
9
10
# File 'lib/cloudpress/renderers/tags.rb', line 7

def initialize(context, tags)
  @context  = context
  @tags     = [tags].flatten.compact
end

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



5
6
7
# File 'lib/cloudpress/renderers/tags.rb', line 5

def tags
  @tags
end

Instance Method Details

#renderObject



12
13
14
15
16
# File 'lib/cloudpress/renderers/tags.rb', line 12

def render
  @context.render layout: 'cloudpress/tags/tags', locals: {renderer: self} do
    wrapped_tags.map(&:render).join("\n").html_safe
  end
end

#wrapped_tagsObject



18
19
20
# File 'lib/cloudpress/renderers/tags.rb', line 18

def wrapped_tags
  @wrapped_tags ||= tags.map {|tag| Cloudpress::Renderers::Tag.new(@context, tag)}
end