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
view used if unspecified in nest.
-
#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, #main_nest_render, #wrap_main
Instance Method Details
#default_nest_view ⇒ Object
view used if unspecified in nest. frequently overridden in other formats
42 43 44 |
# File 'lib/card/format/nesting.rb', line 42 def default_nest_view :name end |
#field_nest(field, opts = {}) ⇒ Object
Shortcut for nesting field cards
27 28 29 30 31 |
# File 'lib/card/format/nesting.rb', line 27 def field_nest field, opts={} fullname = card.name.field(field) unless field.is_a? Card opts[:title] ||= Card.fetch_name(field).vary("capitalized") nest fullname, opts end |
#implicit_nest_view ⇒ Object
46 47 48 |
# File 'lib/card/format/nesting.rb', line 46 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
34 35 36 37 38 |
# File 'lib/card/format/nesting.rb', line 34 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 |