A common pattern in views is to link to a route, eg:
link_to :blogs_path
Should lotus have a helper method for this? I haven’t put much though into the specifics yet but first want to check whether people like this feature.
A common pattern in views is to link to a route, eg:
link_to :blogs_path
Should lotus have a helper method for this? I haven’t put much though into the specifics yet but first want to check whether people like this feature.
@tomkadwill This helper is part of the plan. In a small project, I’ve extracted this helper but not yet ported to Lotus::Helpers
.
module Lotus
module Helpers
module LinkToHelper
def link_to(content, url, options = {}, &blk)
options[:href] = url
html.a(blk || content, options)
end
end
end
end
To be used like this:
<%= link_to('Add a new book', routes.new_books_path, class: 'new-book') %>
What do you think?
@jodosha that looks good. Perhaps you could push up to a branch?
I’m happy to help port to Lotus
Please do. It should be in Lotus::Helpers
. It must inject HtmlHelper
if missing in the current context.
def self.included(base)
base.class_eval do
include Lotus::Helpers::HtmlHelper
end unless base.included_modules.include?(Lotus::Helpers::HtmlHelper)
end
I am going to lock this post as this feature has been added to lotus-helpers