Skip to content

Instantly share code, notes, and snippets.

@fabianvf
Created Apr 25, 2016
Embed
What would you like to do?
How to test erb templates with ruby
<%= conditon ? 'True case' : 'False case' %>)
require 'erb'
condition = false
template = ERB.new File.read("test.erb"), nil, "%"
puts template.result(binding)
@fabianvf
Copy link
Author

fabianvf commented Apr 25, 2016

then just run ruby test.rb

@deepakduggirala
Copy link

deepakduggirala commented Jan 24, 2018

condition spelled wrong in test.erb

<%= conditon ? 'True case' : 'False case' %>) should be <%= condition ? 'True case' : 'False case' %>)

@jimbo8098
Copy link

jimbo8098 commented Jan 27, 2020

Still relevant to this day, thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment