1
0
Fork 0
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:
Ben Hollis 2013-02-08 23:00:29 -08:00
parent ba035882fe
commit 3a3d5bbe3b
2 changed files with 33 additions and 0 deletions

View 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"'

View file

@ -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