Sha256: 699c364b1c84f2cae1f472f76ede46893820f8e7cc4e437c4570e985ba18d69c

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

# Allows to render global partials, for example.
#
#   render partial: "../views/shared/container"
module Cell::ViewModel::Partial
  def process_options!(options)
    super
    return unless partial = options[:partial]

    parts     = partial.split("/")
    view      = parts.pop
    view      = "_#{view}"
    view     += ".#{options[:formats].first}" if options[:formats]
    prefixes  = self.class.view_paths.collect { |path| parts.unshift(path).join("/") }

    options.merge!(view: view, prefixes: prefixes)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cells-4.0.2 lib/cell/partial.rb
cells-4.0.1 lib/cell/partial.rb