lundi 24 octobre 2016

Learning Ruby ERB Templates

I'm trying to learn Ruby ERB Templates using the following guide: Tutorial Link

I am on the "very simple example" section with the following code:

require 'erb'

weekday = Time.now.strftime('%A')
simple_template = "Today is <%= weekday %>."

renderer = ERB.new(simple_template)
puts output = renderer.result()

I wanted to run this code to generate an html file so I created a file called

testing.html.erb

and ran the code with the following command:

erb testing.html.erb > new-file.html

When I did that through the terminal several errors popped up and the html file that was generated was blank. Here are the errors that I received: enter image description here

I was hoping someone could tell me what i was doing wrong. Am I forgetting something? Or am I not running the erb command correctly? Any help would be greatly appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire