diff --git a/middleman-more/features/helpers_relative_link_to.feature b/middleman-more/features/helpers_link_to.feature
similarity index 83%
rename from middleman-more/features/helpers_relative_link_to.feature
rename to middleman-more/features/helpers_link_to.feature
index 6fd8fdb4..3a151819 100644
--- a/middleman-more/features/helpers_relative_link_to.feature
+++ b/middleman-more/features/helpers_link_to.feature
@@ -1,6 +1,6 @@
-Feature: relative_link_to helper
+Feature: link_to helper
- Scenario: relative_link_to produces relative links
+ Scenario: link_to produces relative links
Given a fixture app "indexable-app"
And an empty file named "config.rb"
And a file named "source/link_to.html.erb" with:
@@ -21,7 +21,7 @@ Feature: relative_link_to helper
Then I should see 'absolute: Needs Index'
Then I should see 'relative: Relative'
- Scenario: relative_link_to produces relative links when :relative_links is set to true
+ Scenario: link_to produces relative links when :relative_links is set to true
Given a fixture app "indexable-app"
And a file named "config.rb" with:
"""
@@ -47,7 +47,7 @@ Feature: relative_link_to helper
Then I should see 'absolute: Needs Index'
Then I should see 'relative: Relative'
- Scenario: relative_link_to knows about directory indexes
+ Scenario: link_to knows about directory indexes
Given a fixture app "indexable-app"
And a file named "source/link_to.html.erb" with:
"""
@@ -65,4 +65,14 @@ Feature: relative_link_to helper
Then I should see 'relative: Relative'
When I go to "/link_to/sub/"
Then I should see 'absolute: Needs Index'
- Then I should see 'relative: Relative'
\ No newline at end of file
+ Then I should see 'relative: Relative'
+
+ Scenario: link_to can take a Resource
+ Given a fixture app "indexable-app"
+ And a file named "source/link_to.html.erb" with:
+ """
+ <%= link_to "Needs Index", sitemap.find_resource_by_path("/needs_index.html") %>
+ """
+ And the Server is running at "indexable-app"
+ When I go to "/link_to/"
+ Then I should see 'Needs Index'
diff --git a/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
index 70800c08..cd2adcc7 100644
--- a/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
+++ b/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
@@ -124,8 +124,10 @@ module Middleman
options = args[options_index] || {}
relative = options.delete(:relative)
-
- if url.include? '://'
+ # Handle Resources, which define their own url method
+ if url.respond_to? :url
+ args[url_arg_index] = url.url
+ elsif url.include? '://'
raise "Can't use the relative option with an external URL" if relative
else
# Handle relative urls