I have the following Ruby script:
require 'erubis'
def listing(title, attributes={})
"output" + yield + "more output"
end
example = %Q{<% listing "db/migrate/[date]_create_purchases.rb", :id => "ch01_292" do %>
<![CDATA[class CreatePurchases < ActiveRecord::Migration
def change
create_table :purchases do |t|
t.string :name
t.float :cost
t.timestamps
end
end
end]]>
<% end %>}
chapter = Erubis::Eruby.new(example)
p chapter.result(binding)
I am trying to use a block here and get it to output "output", then the contents in the block, and then "more output", but I cannot get it to work.
I know that ERB worked this way in Rails 2.3 and now works with <%=in Rails 3 ... but I don't use Rails at all. This is just pure ERB.
How can I get it to display all the content?
source
share