Sha256: 55f776f53075068e9218ae8be88e3f666dc626a1f82a906150db34667e005a94

Contents?: true

Size: 1.3 KB

Versions: 88

Compression:

Stored size: 1.3 KB

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The padrino_render plugin adds rendering support that is
    # similar to Padrino's.  While not everything Padrino's
    # rendering supports is supported by this plugin, it
    # currently handles enough to be a drop in replacement for
    # some applications.
    # 
    #   plugin :padrino_render, views: 'path/2/views'
    # 
    # Most notably, this makes the +render+ method default to
    # using the layout, similar to how the +view+ method works
    # in the render plugin.  If you want to call render and not
    # use a layout, you can use the <tt>layout: false</tt>
    # option:
    #
    #   render('test')                 # layout
    #   render('test', layout: false)  # no layout
    #
    # Note that this plugin loads the :partials plugin.
    module PadrinoRender
      # Depend on the render plugin, since this overrides
      # some of its methods.
      def self.load_dependencies(app, opts=OPTS)
        app.plugin :partials, opts
      end

      module InstanceMethods
        # Call view with the given arguments, so that render
        # uses a layout by default.
        def render(template, opts=OPTS)
          view(template, opts)
        end
      end
    end

    register_plugin(:padrino_render, PadrinoRender)
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
roda-3.45.0 lib/roda/plugins/padrino_render.rb
roda-3.44.0 lib/roda/plugins/padrino_render.rb
roda-3.43.1 lib/roda/plugins/padrino_render.rb
roda-3.43.0 lib/roda/plugins/padrino_render.rb
roda-3.42.0 lib/roda/plugins/padrino_render.rb
roda-3.41.0 lib/roda/plugins/padrino_render.rb
roda-3.40.0 lib/roda/plugins/padrino_render.rb
roda-3.39.0 lib/roda/plugins/padrino_render.rb
roda-3.38.0 lib/roda/plugins/padrino_render.rb
roda-3.37.0 lib/roda/plugins/padrino_render.rb
roda-3.36.0 lib/roda/plugins/padrino_render.rb
roda-3.35.0 lib/roda/plugins/padrino_render.rb
roda-3.34.0 lib/roda/plugins/padrino_render.rb
roda-3.33.0 lib/roda/plugins/padrino_render.rb
roda-3.32.0 lib/roda/plugins/padrino_render.rb
roda-3.31.0 lib/roda/plugins/padrino_render.rb
roda-3.30.0 lib/roda/plugins/padrino_render.rb
roda-3.29.0 lib/roda/plugins/padrino_render.rb
roda-3.28.0 lib/roda/plugins/padrino_render.rb
roda-3.27.0 lib/roda/plugins/padrino_render.rb