Class: Scrivito::ChildListTag::ObjTag

Inherits:
Struct
  • Object
show all
Defined in:
app/cms/scrivito/child_list_tag.rb

Overview

This is a helper class for ScrivitoHelper#scrivito_tag_list.

Instance Method Summary collapse

Instance Method Details

#tag(tag_name, html_options = {}, &block) ⇒ String

Note:

This method can be called only once per child.

Renders HTML for the corresponding child with in-place editing enabled.

Examples:

Render a div element containing text, and assign to it the my_list_element CSS class.

list.tag(:div, class: "my_list_element") do
  "random content"
end

Parameters:

  • tag_name (String, Symbol)

    Name of the HTML tag (e.g. :li or :div).

  • html_options (Hash) (defaults to: {})

    Options to be passed to content_tag. Use them to add HTML attributes to the tag.

Returns:

  • (String)

    The rendered HTML tag.

See Also:



86
87
88
89
90
91
# File 'app/cms/scrivito/child_list_tag.rb', line 86

def tag(tag_name, html_options = {}, &block)
  raise '"list.tag" can only be called once per iteration!' if @rendered
  @tag_name = tag_name
  @rendered = render(html_options, &block)
  nil
end