user793468
user793468

Reputation: 4976

Encapsulate the rendering of HTML

Can someone explain me what it means when they say:

"HTML Helpers enables to encapsulate the rendering of HTML"

Does it mean it will restrict access to the HTML attributes of an object? What if I am using CSS, jquery, Javascript, will it display my JS/jquery and CSS in page source?

Upvotes: 0

Views: 251

Answers (2)

Oded
Oded

Reputation: 499312

HTML helpers are bits of code that will render out the HTML, instead of you writing out the HTML for each and every piece of data directly in the view.

They encapsulate it - meaning they take care of what HTML is output.

Upvotes: 1

ilan berci
ilan berci

Reputation: 3881

By "encapsulating the rendering", they are referring to the encapsulation of the functionality of rendering html.

If there is a common piece of html you render often, (the rails form helpers for example), if you insert the code (or the code building functionality within a helper), each time you need to render that html (or a variant of it) , you merely call the helper method thereby keeping your code "dry" (html code in this case)

Upvotes: 1

Related Questions