How can I use views and layouts with Ruby and ERB (not Rails)?

前端 未结 4 582
闹比i
闹比i 2020-12-20 06:08

How can I use views and layouts with Ruby and ERB (not Rails)?

Today i\'m using this code to render my view:

def render(template_path, context = sel         


        
4条回答
  •  感动是毒
    2020-12-20 06:28

    If you use the Tilt gem (which I think is what Sinatra uses) you could do something like

    template_layout = Tilt::ERBTemplate.new(layout)
    template_layout.render { 
      Tilt::ERBTemplate.new(template).render(context.get_binding)
    }
    

提交回复
热议问题