Module: Card::Format::Nesting
- Included in:
- Card::Format
- Defined in:
- lib/card/format/nesting.rb,
lib/card/format/nesting/main.rb,
lib/card/format/nesting/mode.rb,
lib/card/format/nesting/subformat.rb
Overview
the core of the nesting api
Defined Under Namespace
Modules: Main, Mode, Subformat
Instance Method Summary collapse
-
#default_nest_view ⇒ Object
frequently overridden.
-
#field_nest(field, opts = {}) ⇒ Object
Shortcut for nesting field cards.
- #implicit_nest_view ⇒ Object
- #nest(cardish, view_opts = {}, format_opts = {}) ⇒ Object
-
#nest_path(name, nest_opts = {}) ⇒ Object
create a path for a nest with respect to the nest options.
Methods included from Mode
#configured_view_in_closed_mode, #hide_view_in_edit_mode?, #modal_nest_view, #nest_mode, #view_in_closed_mode, #view_in_edit_mode, #with_altered_nest_mode, #with_nest_mode
Methods included from Subformat
#depth, #field_subformat, #focal?, #inherit, #main, #main?, #root, #root?, #subformat
Methods included from Main
#already_mained?, #main!, #main_nest, #main_nest?, #main_nest_options, #wrap_main
Instance Method Details
#default_nest_view ⇒ Object
frequently overridden
40 41 42 |
# File 'lib/card/format/nesting.rb', line 40 def default_nest_view :name end |
#field_nest(field, opts = {}) ⇒ Object
Shortcut for nesting field cards
27 28 29 30 |
# File 'lib/card/format/nesting.rb', line 27 def field_nest field, opts={} field = card.name.field(field) unless field.is_a? Card nest field, opts end |
#implicit_nest_view ⇒ Object
44 45 46 |
# File 'lib/card/format/nesting.rb', line 44 def implicit_nest_view voo_items_view || default_nest_view end |
#nest(cardish, view_opts = {}, format_opts = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/card/format/nesting.rb', line 12 def nest cardish, view_opts={}, format_opts={} return "" if nest_invisible? nest = Card::Format::Nest.new self, cardish, view_opts, format_opts nest.prepare do |subformat, view| rendered = count_chars { subformat.render view, view_opts } block_given? ? yield(rendered, view) : rendered end end |
#nest_path(name, nest_opts = {}) ⇒ Object
create a path for a nest with respect to the nest options
33 34 35 36 37 |
# File 'lib/card/format/nesting.rb', line 33 def nest_path name, nest_opts={} path_opts = { slot: nest_opts.clone, mark: name } path_opts[:view] = path_opts[:slot].delete :view path path_opts end |