Sha256: ff47713693da06e4209eade6709d7bba33c173f32568382431059ece5530983b

Contents?: true

Size: 991 Bytes

Versions: 41

Compression:

Stored size: 991 Bytes

Contents

class Card
  class Format
    module Nesting
      # Handle the main nest
      module Main
        def wrap_main
          yield # no wrapping in base format
        end

        def main_nest opts
          wrap_main do
            main.rendered || main_nest_render(opts)
          end
        end

        def main_nest_render opts={}
          with_nest_mode :normal do
            if block_given?
              block.call
            else
              nest root.card, opts.merge(main_view: true, main: true)
            end
          end
        end

        def main_nest? nest_name
          nest_name == "_main" # && !root.already_mained?
        end

        def already_mained?
          return true if @main || @already_main

          @already_main = true
          false
        end

        def main!
          @main = true
        end

        # view=edit&items=closed
        def main_nest_options
          inherit(:main_opts) || {}
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
card-1.108.1 lib/card/format/nesting/main.rb
card-1.108.0 lib/card/format/nesting/main.rb
card-1.107.0 lib/card/format/nesting/main.rb
card-1.106.0 lib/card/format/nesting/main.rb
card-1.105.6 lib/card/format/nesting/main.rb
card-1.105.5 lib/card/format/nesting/main.rb
card-1.105.4 lib/card/format/nesting/main.rb
card-1.105.3 lib/card/format/nesting/main.rb
card-1.105.2.pre1 lib/card/format/nesting/main.rb
card-1.105.2 lib/card/format/nesting/main.rb
card-1.105.1 lib/card/format/nesting/main.rb
card-1.105.0 lib/card/format/nesting/main.rb
card-1.104.2 lib/card/format/nesting/main.rb
card-1.104.1 lib/card/format/nesting/main.rb
card-1.104.0 lib/card/format/nesting/main.rb
card-1.103.4 lib/card/format/nesting/main.rb
card-1.103.3 lib/card/format/nesting/main.rb
card-1.103.2 lib/card/format/nesting/main.rb
card-1.103.1 lib/card/format/nesting/main.rb
card-1.103.0 lib/card/format/nesting/main.rb