Sha256: c6644c3626abc2c3e8da5ae435c93788c9db4d13b27d57f6068cb2fcc89c1493

Contents?: true

Size: 613 Bytes

Versions: 2

Compression:

Stored size: 613 Bytes

Contents

module Locomotive::Steam
  module Middlewares

    class TemplatizedPage < Base

      def _call(env)
        super

        if self.page && self.page.templatized?
          self.set_content_entry!(env)
        end

        app.call(env)
      end

      protected

      def set_content_entry!(env)
        %r(^#{self.page.safe_fullpath.gsub('*', '([^\/]+)')}$) =~ self.path

        permalink = $1

        if content_entry = self.page.content_type.find_entry(permalink)
          env['steam.content_entry'] = content_entry
        else
          env['steam.page'] = nil
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.2.pre.beta lib/locomotive/steam/middlewares/templatized_page.rb
locomotivecms_steam-0.1.1 lib/locomotive/steam/middlewares/templatized_page.rb