Sha256: e28c1b8e911ad14d5cc8c5885771b9ca0e078f4f59a74bfa030eb38bfa432994

Contents?: true

Size: 708 Bytes

Versions: 19

Compression:

Stored size: 708 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The symbol_views plugin allows match blocks to return
    # symbols, and consider those symbols as views to use for the
    # response body.  So you can take code like:
    #
    #   r.root do
    #     view :index
    #   end
    #   r.is "foo" do
    #     view :foo
    #   end
    #
    # and DRY it up:
    #
    #   r.root do
    #     :index
    #   end
    #   r.is "foo" do
    #     :foo
    #   end
    module SymbolViews
      def self.configure(app)
        app.plugin :custom_block_results
        app.opts[:custom_block_results][Symbol] = :view
      end
    end

    register_plugin(:symbol_views, SymbolViews)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
roda-3.86.0 lib/roda/plugins/symbol_views.rb
roda-3.85.0 lib/roda/plugins/symbol_views.rb
roda-3.84.0 lib/roda/plugins/symbol_views.rb
roda-3.83.0 lib/roda/plugins/symbol_views.rb
roda-3.82.0 lib/roda/plugins/symbol_views.rb
roda-3.81.0 lib/roda/plugins/symbol_views.rb
roda-3.79.0 lib/roda/plugins/symbol_views.rb
roda-3.78.0 lib/roda/plugins/symbol_views.rb
roda-3.77.0 lib/roda/plugins/symbol_views.rb
roda-3.76.0 lib/roda/plugins/symbol_views.rb
roda-3.75.0 lib/roda/plugins/symbol_views.rb
roda-3.74.0 lib/roda/plugins/symbol_views.rb
roda-3.73.0 lib/roda/plugins/symbol_views.rb
roda-3.72.0 lib/roda/plugins/symbol_views.rb
roda-3.71.0 lib/roda/plugins/symbol_views.rb
roda-3.70.0 lib/roda/plugins/symbol_views.rb
roda-3.69.0 lib/roda/plugins/symbol_views.rb
roda-3.68.0 lib/roda/plugins/symbol_views.rb
roda-3.67.0 lib/roda/plugins/symbol_views.rb