Created
March 22, 2015 03:21
-
-
Save dylanjha/fe4a8daf5f978139f2ea to your computer and use it in GitHub Desktop.
Rake task to load erb
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
<%# Put this file in app/views/test.html.erb %> | |
<h1>Here is some html</h2> | |
<%= name %> |
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
task :erb_example do | |
string = Rails.root.join("app/views/test.html.erb").read | |
name = "Example Name" | |
result = ERB.new(string).result(binding) | |
#>> "<h1>Here is some html</h2>\n\nhere is name" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment