Sha256: f2a0ac020565621f0242d72f88b7d4de501a2b04449517a3c2b5a882cf07635b

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

require 'lotus/view/rendering/template_finder'

module Lotus
  module View
    module Rendering
      # Find a partial for the current view context.
      # It's used when a template wants to render a partial.
      #
      # @see Lotus::View::Rendering::Partial
      # @see Lotus::View::Rendering::TemplateFinder
      #
      # @api private
      # @since 0.1.0
      class PartialFinder < TemplateFinder
        # Template file name prefix.
        # By convention a partial file name starts with this prefix.
        #
        # @api private
        # @since 0.1.0
        #
        # @example
        #   "_sidebar.html.erb"
        PREFIX = '_'.freeze

        protected
        def template_name
          *all, last = partial_name.split(separator)
          all.push( last.prepend(prefix) ).join(separator)
        end

        def partial_name
          @options[:partial]
        end

        def prefix
          PREFIX
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lotus-view-0.4.2 lib/lotus/view/rendering/partial_finder.rb
lotus-view-0.4.1 lib/lotus/view/rendering/partial_finder.rb
lotus-view-0.4.0 lib/lotus/view/rendering/partial_finder.rb
lotus-view-0.3.0 lib/lotus/view/rendering/partial_finder.rb
lotus-view-0.2.0 lib/lotus/view/rendering/partial_finder.rb
lotus-view-0.1.0 lib/lotus/view/rendering/partial_finder.rb