Sha256: 4521d175106538f2b22d5ccc890ab506b4fb420bbaf41a4572bd48697bb94b9a

Contents?: true

Size: 694 Bytes

Versions: 18

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

module MuchRails; end
module MuchRails::Layout; end

module MuchRails::Layout::Helper
  # This is used to render layouts. It is designed to be used in
  # the Rails layout template to render the nested layouts.
  def much_rails_render_layouts(view_model, &content)
    unless view_model.is_a?(MuchRails::Layout)
      raise(
        TypeError,
        "A View Model that mixes in MuchRails::Layout expected; "\
        "got #{view_model.class}.",
      )
    end
    view_model
      .layouts
      .reverse
      .reduce(content){ |render_proc, template_path|
        ->{ render(File.join("layouts", template_path), &render_proc) }
      }
      .call
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
much-rails-0.4.3 lib/much-rails/layout/helper.rb
much-rails-0.4.2 lib/much-rails/layout/helper.rb
much-rails-0.4.1 lib/much-rails/layout/helper.rb
much-rails-0.4.0 lib/much-rails/layout/helper.rb
much-rails-0.3.0 lib/much-rails/layout/helper.rb
much-rails-0.2.8 lib/much-rails/layout/helper.rb
much-rails-0.2.7 lib/much-rails/layout/helper.rb
much-rails-0.2.6 lib/much-rails/layout/helper.rb
much-rails-0.2.5 lib/much-rails/layout/helper.rb
much-rails-0.2.4 lib/much-rails/layout/helper.rb
much-rails-0.2.3 lib/much-rails/layout/helper.rb
much-rails-0.2.2 lib/much-rails/layout/helper.rb
much-rails-0.2.1 lib/much-rails/layout/helper.rb
much-rails-0.2.0 lib/much-rails/layout/helper.rb
much-rails-0.1.3 lib/much-rails/layout/helper.rb
much-rails-0.1.2 lib/much-rails/layout/helper.rb
much-rails-0.1.1 lib/much-rails/layout/helper.rb
much-rails-0.1.0 lib/much-rails/layout/helper.rb