Learn to render a template file as a response to a request. A template file can contain Ruby code and be populated with dynamic data. Sinatra supports many different template languages, but we will be using ERB which is the most popular and is built-in to
- [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 simple string.…In the first example here, you see that I've defined…
- Installing Sinatra
- Launching the server
- Defining routes
- Using route patterns and parameters
- Redirecting requests
- Rendering dynamic templates
- Using partial templates and layouts
- Defining custom helpers
Skill Level Intermediate
Ruby on Rails 5 Essential Trainingwith Kevin Skoglund10h 21m Beginner
Ruby on Rails: Get More From ActiveRecordwith Kevin Skoglund4h 27m Intermediate
3. Helpers and Filters
4. Useful Techniques
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.