View templates

Keyboard Shortcuts

Learn about ERB and how to use ERB tags to embed dynamic content into view templates. There are two types of ERB tags. Both tag types allow performing Ruby calculations, but one of them will output the result to the template while the other will not.

- [Narrator] We've seen how controllers can either…redirect or render a view template.…In this movie we're going to take a closer look…at the view templates themselves.…So far, view templates have been composed…of only HTML, we could use just HTML,…but that won't be dynamic or data-based driven.…It would be much better if we could embed Ruby code…into our templates so would could then put…dynamic information into them.…To do that, we're going to use ERB.…ERB is short for "Embedded Ruby."…It's an eRuby templating system to allow us…to embed Ruby inside our HTML pages.…

You may remember those letters were part of our…template file name before.…We had hello.html.erb.…What that means is we have a template named hello,…we're going to process it with ERB,…and when we're done, the final output format…will be in HTML.…There are other templating systems you can install and use…instead of ERB, but ERB is the default one…that comes with Rails.…We can have different output formats, too, not just HTML.…We can have XML, JSON, javascript or something else.…

Resume Transcript Auto-Scroll

Author

Released

9/28/2016

Learn how to create full-featured, object-oriented web applications with the latest version of the popular, open-source Ruby on Rails framework. Ruby on Rails 5 Essential Training covers the essential features of the framework, along with best practices and real-world development techniques, resulting in a complete application with dynamic, database-driven content. Follow along to build your own version of the example project, a data-driven content management system, while you learn how to route browser requests, structure databases, render pages with dynamic content, process and validate form data, and configure authentication. Instructor Kevin Skoglund, founder of web development agency Nova Fabrica, also introduces the design principles of CRUD and helps you master Rail's built-in helpers. By the end of the course, you should be able to use Ruby on Rails to build robust web applications that are both easy to scale and maintain.