Ruby templates: How to pass variables into inlined ERB?

前端 未结 10 1710
陌清茗
陌清茗 2020-11-30 21:18

I have an ERB template inlined into Ruby code:

require \'erb\'

DATA = {
    :a => \"HELLO\",
    :b => \"WORLD\",
}

template = ERB.new <<-EOF
          


        
10条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 22:08

    This article explains this nicely.

    http://www.garethrees.co.uk/2014/01/12/create-a-template-rendering-class-with-erb/

提交回复
热议问题