Join Kevin Skoglund for an in-depth discussion in this video Template files, part of Ruby: Files, Formats, Templates.
- [Instructor] So far in our explorations of ERB,…we've been working with simple strings as our templates.…In this movie, I want us to talk about…how we can use template files instead.…Hopefully, you've realized that the process is very simple.…All we need to do is require ERB,…set any instance variables we want,…and then when it comes time to provide the template,…instead of having a simple string,…well, we just read from the file.…We know how to do that.…We've learned how to read from a file…and turn it into a string inside Ruby.…Then we can take that template, pass into into ERB,…give it its bindings, and it'll put it all together…and give us the result that we want from this template file.…
The process is really that easy.…Let's demonstrate.…Let's go into our project…and let's start by creating a new file.…It's going to be a template file.…And you can call it anything you want,…but I'm call call mine inquiry.txt.erb.…This is a convention from Ruby on Rails that I'm borrowing,…which basically says that if want to process it with ERB,…
- File system basics
- Writing to and reading from files
- Renaming, deleting, and copying files
- Creating and editing directories
- Working with common data formats
- ERB templating
Skill Level Beginner
Ruby on Rails 5 Essential Trainingwith Kevin Skoglund10h 21m Beginner
1. The File System
2. Work with Files
3. Work with Directories
4. Common Data Formats
5. ERB Templating
- 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.