Sha256: 9fa6bfe778eb6de2d9613018ab469abfc1135baf8e0b58d4c6291c18372cf2fd

Contents?: true

Size: 868 Bytes

Versions: 30

Compression:

Stored size: 868 Bytes

Contents

module Scrivito

module TagRenderer

  VOID_TAGS = %w[area base br col command embed hr img input keygen
      link meta param source track wbr]

  def render(given_options = {}, &block)
    TagRenderer.render(view, self, given_options, &block)
  end

  def html_options
    {}
  end

  def self.render(view, tag, given_options, &block)
    content = tag.content(&block)
    tag_name = tag.tag_name
    options = given_options
      .merge(tag.html_options)
      .merge(formatted_options(tag))

    if VOID_TAGS.include?(tag_name.to_s)
      view.tag(tag_name, options)
    else
      view.content_tag(tag_name, content, options)
    end
  end

  private_class_method def self.formatted_options(tag)
    formatted_options = {}
    tag.options.each do |key, value|
      formatted_options["data-scrivito-#{key}"] = value
    end

    formatted_options
  end

end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
scrivito_sdk-1.12.0.rc2 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.12.0.rc1 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.11.0 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.11.0.rc1 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.10.0 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.10.0.rc5 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.10.0.rc4 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.10.0.rc3 app/cms/scrivito/tag_renderer.rb
scrivito_sdk-1.10.0.rc2 lib/scrivito/tag_renderer.rb
scrivito_sdk-1.10.0.rc1 lib/scrivito/tag_renderer.rb