ruby - How to load a ERB, edit and save it to the disk using Rails and ERB -
ok, imagine have template file:
<virtualhost *:80> <%= "servername #{@user[:domain]}" %> <%= "serveralias #{@user[:domain]}" &> documentroot "/my/app/path" errorlog <%= "/private/var/log/apache2/#{@user[:domain]}-error_log" %> customlog <%= "/private/var/log/apache2/#{@user[:domain]}-access_log" %> common <directory "/my/app/path"> options indexes followsymlinks allowoverride order allow,deny allow </directory> </virtualhost>
and load file, replace variable actual data , save file?
i know gist of read , save files disk ruby, i'm not sure how replace variables actual data while saving it.
any ideas?
@foo = "world" think need erb.new("hello <%= @foo%>").result # "hello world"
http://ruby-doc.org/stdlib-1.9.3/libdoc/erb/rdoc/erb.html#method-i-result
Comments
Post a Comment