create custom html helpers in ruby on rails -


I started programming on the ASP.NET MVC framework a year ago. recently. I am learning Rail Framework on Ruby ASP.NET MVC has the "Custom HTML Assistant" feature, so I can make my own html assistant

  <% = Html.MyOwnHtmlHelper ( )% & Gt;  

I have learned that Ruby has html helpers such as

  <% text_area%>  

which presents on HTML

I have a question, can I make my own HTML to create my own HTML?

To create a new helper:

  1. Choose a name, for example tags_helper.rb
  2. Create a file in the / app / helpers directory
  3. In this case according to a module file name

     Module Tags Helper End  
  4. Define your assistant as the method

      Module Tag Helper Def Hello-World ( Name) "Hello # {name}" and end  

You can now go to hello_world assistant and Your view can use the method.


Comments