Reputation: 2787
I've starting programming on ASP.NET MVC Framework a year ago. Recently. I've learning Ruby On Rails Framework There is "custom html helper" feature in ASP.NET MVC So I can create my own html helper
<%= Html.MyOwnHtmlHelper() %>
I've learned that there is html helpers in Ruby such as
<% text_area %>
which render at html
I have a question. Can I create my own html helper for rendering my own html?
Upvotes: 44
Views: 31428
Reputation: 176562
To create a new helper:
create a module according to the file name. In this case
module TagsHelper
end
define your helper as method
module TagsHelper
def hello_world(name)
"hello #{name}"
end
end
Now you can use the hello_world
helper method in your view.
Upvotes: 66