render
is a method from Rails (and some other frameworks), and isn’t available in pure Haml. To include the contents of another file directly you could simply read the file in your Haml:
.header
hello
= File.read "b.html"
which gives the input you expect in this case.
This is simple inclusion of the file contents directly in the output though. If you want the other file to be processed in some way you will need to do it yourself, e.g. if you want to render another Haml file you could do something like this:
.header
Some text
= Haml::Engine.new(File.read("a_file.haml")).render
If you’re doing this with different template libraries you might want to look at Tilt.
These examples are very simple and you should’t really use them for something like a web app – they’re only really for generating static files. If you’re learning Haml to use in web app development then the helpers from whatever framework you’re using will still be available and you should use those, e.g. render
in Rails; haml
, erb
, markdown
etc. in Sinatra.