Class: Toolsmith::Views::DefinitionList
- Defined in:
- lib/toolsmith/views/definition_list.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ horizontal: true }
Instance Attribute Summary collapse
-
#content_block ⇒ Object
readonly
Returns the value of attribute content_block.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Base
Instance Method Summary collapse
- #define(term, description) ⇒ Object
-
#initialize(context, options = {}, &block) ⇒ DefinitionList
constructor
A new instance of DefinitionList.
- #to_s ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(context, options = {}, &block) ⇒ DefinitionList
Returns a new instance of DefinitionList.
8 9 10 11 12 |
# File 'lib/toolsmith/views/definition_list.rb', line 8 def initialize(context, ={}, &block) @content_block = block if block_given? @options = DEFAULT_OPTIONS.merge() super(context, &nil) end |
Instance Attribute Details
#content_block ⇒ Object (readonly)
Returns the value of attribute content_block.
6 7 8 |
# File 'lib/toolsmith/views/definition_list.rb', line 6 def content_block @content_block end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/toolsmith/views/definition_list.rb', line 6 def @options end |
Instance Method Details
#define(term, description) ⇒ Object
14 15 16 17 |
# File 'lib/toolsmith/views/definition_list.rb', line 14 def define(term, description) description = description.blank? ? " ".html_safe : description content_tag(:dt, term) + content_tag(:dd, description) end |
#to_s ⇒ Object
19 20 21 22 |
# File 'lib/toolsmith/views/definition_list.rb', line 19 def to_s content = context.capture(self, &content_block) content_tag :dl, content, end |