diff --git a/middleman-core/features/request_params.feature b/middleman-core/features/request_params.feature new file mode 100644 index 00000000..968d0bfc --- /dev/null +++ b/middleman-core/features/request_params.feature @@ -0,0 +1,6 @@ +Feature: Support request parameters + Scenario: Use request params in a template + Given the Server is running at "request-app" + When I go to "/index.html?say=Hello+World" + Then I should see "Quote Hello World" + Then I should see "Symbol Hello World" diff --git a/middleman-core/fixtures/request-app/config.rb b/middleman-core/fixtures/request-app/config.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/fixtures/request-app/source/index.html.erb b/middleman-core/fixtures/request-app/source/index.html.erb new file mode 100644 index 00000000..f87a2bd9 --- /dev/null +++ b/middleman-core/fixtures/request-app/source/index.html.erb @@ -0,0 +1,3 @@ +Dot <%= request.params.say %> +Quote <%= request.params["say"] %> +Symbol <%= request.params[:say] %> diff --git a/middleman-core/lib/middleman-core/base.rb b/middleman-core/lib/middleman-core/base.rb index 7ab77383..1631129f 100644 --- a/middleman-core/lib/middleman-core/base.rb +++ b/middleman-core/lib/middleman-core/base.rb @@ -265,7 +265,10 @@ class Middleman::Base # @return [void] def current_path=(path) @_current_path = path - @request = ::Thor::CoreExt::HashWithIndifferentAccess.new({ :path => path }) + @request = ::Thor::CoreExt::HashWithIndifferentAccess.new({ + :path => path, + :params => req ? ::Thor::CoreExt::HashWithIndifferentAccess.new(req.params) : {} + }) end # Initialize the Middleman project