From the course: Learning Sinatra

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Render templates

Render templates

From the course: Learning Sinatra

Start my 1-month free trial

Render templates

- [Instructor] In the previous movie, we learned how to render static files. Now we're ready to learn to render a template. Templates are different from static files. Templates are formatted documents which are meant to be reused and the way that we reuse them is by putting code inside of them. Having code inside the template is what makes them dynamic. It's what makes them different from static files. A static file is always going to return the exact same content, but a template will vary depending on the conditions when the code runs. Sinatra includes support for many of the popular template languages. For examble, ERB, Haml, Builder, Markdown and Textile are some of the most popular ones. In this course, we're going to working exclusively with ERB because it's built into Ruby and it's easy to learn. Let me give you an example: first, in order to render a template we have to have a template. Now a template can be a file, we'll talk about that in moment, but it can also just be a…

Contents