mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Override form_tag to use url_for. Fixes #739
This commit is contained in:
parent
ba035882fe
commit
3a3d5bbe3b
2 changed files with 33 additions and 0 deletions
26
middleman-more/features/helpers_form_tag.feature
Normal file
26
middleman-more/features/helpers_form_tag.feature
Normal file
|
@ -0,0 +1,26 @@
|
|||
Feature: form_tag helper
|
||||
|
||||
Scenario: form_tag produces relative links
|
||||
Given a fixture app "indexable-app"
|
||||
And an empty file named "config.rb"
|
||||
And a file named "source/form_tag.html.erb" with:
|
||||
"""
|
||||
absolute: <% form_tag "/needs_index.html#absolute", :relative => true do %>
|
||||
<% end %>
|
||||
relative: <% form_tag "needs_index.html#relative", :relative => true do %>
|
||||
<% end %>
|
||||
"""
|
||||
And a file named "source/form_tag/sub.html.erb" with:
|
||||
"""
|
||||
absolute: <% form_tag "/needs_index.html#absolute", :relative => true do %>
|
||||
<% end %>
|
||||
relative: <% form_tag "../needs_index.html#relative", :relative => true do %>
|
||||
<% end %>
|
||||
"""
|
||||
And the Server is running at "indexable-app"
|
||||
When I go to "/form_tag.html"
|
||||
Then I should see 'action="needs_index.html#absolute"'
|
||||
Then I should see 'action="needs_index.html#relative"'
|
||||
When I go to "/form_tag/sub.html"
|
||||
Then I should see 'action="../needs_index.html#absolute"'
|
||||
Then I should see 'action="../needs_index.html#relative"'
|
|
@ -203,6 +203,13 @@ module Middleman
|
|||
|
||||
super(*args, &block)
|
||||
end
|
||||
|
||||
# Modified Padrino form_for that uses Middleman's url_for
|
||||
# to transform the URL.
|
||||
def form_tag(url, options={}, &block)
|
||||
url = url_for(url, options)
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue