Partial HAML templating in Ruby without Rails

后端 未结 5 710
Happy的楠姐
Happy的楠姐 2020-12-24 08:23

I really don’t need the overhead of Rails for my very small project, so I’m trying to achieve this just using just plain Ruby and HAML.

I want to include another HAM

5条回答
  •  死守一世寂寞
    2020-12-24 08:57

    I've had great success just using the instructions posted by David Richards in a concatenated way, without variables, like this:

    = Haml::Engine.new(File.read('/Volumes/Project/file_to_include.haml')).render

    There's obviously a more elegant way. But for someone who just wants to include one or two files, this should work nicely. It's a drawback that all base files using these includes have to be recompiled after some changes to the latter. It might be worthwile to just use php include if the environment allows that.

提交回复
热议问题