Rails: Is it possible to write view helpers with HAML syntax?

后端 未结 4 1223
萌比男神i
萌比男神i 2021-02-12 19:05

During refactoring it would be quite handy just to copy part of HAML template and paste it to helper\'s code. Currently in such cases 1) I have to rewrite that part of view from

4条回答
  •  Happy的楠姐
    2021-02-12 19:56

    From the reference:

    def render_haml(code)
        engine = Haml::Engine.new(code)
        engine.render
    end
    

    This initiates a new Haml engine and renders it.

提交回复
热议问题