Created
April 25, 2016 17:33
-
-
Save fabianvf/61fd184a49067f3a3e95fd8ce5da6897 to your computer and use it in GitHub Desktop.
How to test erb templates with ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= conditon ? 'True case' : 'False case' %>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
condition = false | |
template = ERB.new File.read("test.erb"), nil, "%" | |
puts template.result(binding) |
Still relevant to this day, thanks for this!
Thanks for this. Just what I needed.
Very helpful
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
condition spelled wrong in test.erb
<%= conditon ? 'True case' : 'False case' %>) should be <%= condition ? 'True case' : 'False case' %>)