Including one erb file into another

前端 未结 4 775
悲&欢浪女
悲&欢浪女 2020-12-08 07:41

I\'m writing a command-line tool that will ultimately output an HTML report. The tool is written in Ruby. (I am not using Rails). I\'m trying to keep the logic of the applic

4条回答
  •  忘掉有多难
    2020-12-08 07:58

    From within my .erb file, I had to do this:

    <%= ERB.new(File.read('pathToFile/myFile.erb'), nil, nil, '_sub01').result(binding) %>
    

    The other answers in this thread assumed you had a variable with your content in it. This version retrieves the content.

提交回复
热议问题