HTML Abstract Markup Language for Julia. Inspired by Ruby's HAML.
Build Status | Test coverage |
---|---|
The easiest way to use HAML in Julia is in the form of the haml""
macro.
Just write your HAML code in-line and it will expand to a string:
julia> using HAML
julia> link = "https://youtu.be/dQw4w9WgXcQ"
julia> haml"""
%html
%body
%a(href=link) Hello, world!
""" |> print
<html>
<body>
<a href='https://youtu.be/dQw4w9WgXcQ'>Hello, world!</a>
</body>
</html>
It is also possible to store HAML in a file and execute it from there:
julia> write("/tmp/test.hamljl", """
%html
%body
%a(href=\$link)= \$greeting
""")
47
julia> render(stdout, "/tmp/test.hamljl", variables=(link=link, greeting="Hello, world!",))
<html>
<body>
<a href='https://youtu.be/dQw4w9WgXcQ'>Hello, world!</a>
</body>
</html>
In this case, note that input variables need to be quoted with a dollar sign $
.
This distinguishes them from file-local variables.
If you are already familiar with Ruby-flavoured HAML, read about the differences here. If not, either use read the getting started guide or the syntax reference.