1.

How Do I Render Partials?

Answer»

Sinatra’s template system is simple enough that it can be used for page and fragment level rendering tasks. The erb and haml methods simply RETURN a STRING.

SINCE Sinatra 1.1, you can use the same calls for partials you use in the ROUTES:

<%= erb :partial %>

In versions prior to 1.1, you need to MAKE sure you disable layout rendering as follows:

<%= erb :partial, :layout => false %>

If you are interested in more robust partials solutions, check out the sinatra-recipes project, which has articles on using the sinatra-partial gem or implementing your own Rails-style partials.

Sinatra’s template system is simple enough that it can be used for page and fragment level rendering tasks. The erb and haml methods simply return a string.

Since Sinatra 1.1, you can use the same calls for partials you use in the routes:

<%= erb :partial %>

In versions prior to 1.1, you need to make sure you disable layout rendering as follows:

<%= erb :partial, :layout => false %>

If you are interested in more robust partials solutions, check out the sinatra-recipes project, which has articles on using the sinatra-partial gem or implementing your own Rails-style partials.



Discussion

No Comment Found