Templates are used to specify the contents of files. When we have a file to be created and its content needs to be created dynamically, we use templates. Templates are written in the ERB templating language. ERB is supported by Ruby. You can refer to http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html for more information. To use a template, we need to create a folder named
templates under the relevant module. In the
templates folder, we can use any file name with the
We will start with a simple file creation example. As you will remember, our first module was the
helloworld module and we created a file in the hosts from static content. Now let's go back to this and add some dynamic content.
To refresh ...