Including one erb file into another

前端 未结 4 772
悲&欢浪女
悲&欢浪女 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 08:14

    I'm needing this in a Sinatra app, and I find that I can just call it the same way I called the original:

    In the sinatra app, I call the index:

    erb :index
    

    Then, in the index template, I can do the same for any sub-template:

    <%= erb :controls %>

    ..which shows the 'controls.erb' template.

提交回复
热议问题