# \[ANN\] HAML.jl - Ruby's favourite templating language comes to Julia

**URL:** <https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066>\
**Category:** Package Announcements\
**Created:** [September 23, 2019, 10:16am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066 "2019-09-23T10:16:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [September 23, 2019, 10:16am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/1 "2019-09-23T10:16:02Z")

</div>

I just released an [early version of HAML.jl](https://github.com/tkluck/HAML.jl) - a Julia-dialect of [Ruby’s HAML templating language](http://haml.info). (The release is pending [this merge request](https://github.com/JuliaRegistries/General/pull/3761).)

Thanks to Julia’s macros and code generation features, this package compiles the templates to native code. It also preserves file&line info for easier debugging.

This is mostly a for-fun effort, but I’m hoping to eventually use if I replace [StatProfilerHTML.jl](https://github.com/tkluck/StatProfilerHTML.jl)’s perl backend by a pure Julia version.

Thoughts and contributions welcome!

---

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [September 24, 2019, 8:08am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/2 "2019-09-24T08:08:34Z")

</div>

Awesome, thanks so much! I’ve wanted this for a while - I’ll check it out, I’d love to add HAML templates support to Genie (happy to read that it compiles to native Julia, I was afraid it would use string parsing and evaling!).

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [September 24, 2019, 9:11am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/3 "2019-09-24T09:11:49Z")

</div>

Cool! Let me know if you’d need anything from my side (API changes, …) to make that a smooth experience for you and your users.

---

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [September 24, 2019, 10:27am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/4 "2019-09-24T10:27:45Z")

</div>

Thank you 🙂 How much of the HAML spec does the package implement?

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [September 24, 2019, 10:34am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/5 "2019-09-24T10:34:25Z")

</div>

Well, it’s obviously not actually implementing the spec because it’s a Julia-flavoured dialect. That affects, for example, the syntax for attributes.

Having said that, the parts that I haven’t done yet are:

- eating whitespace with `<` and `>`
- allowing non-escaped interpolations
- allowing interpolations in text content
- multiline with `|`
- helper methods

Also, as a departure from haml, I’m considering disallowing literal html unless explicitly unescaped with `!`. Having worked in e-commerce, I’m paranoid about XSS 🙂

---

<div class="post-metadata">

**Author:** ![christopher-dG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher-dg/32/7387_2.png) [@christopher-dG](https://discourse.julialang.org/u/christopher-dG)\
**Post date:** [September 26, 2019, 8:47am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/6 "2019-09-26T08:47:14Z")

</div>

Just tried to install HAML from the Git URL, and it looks like you need to add DataStructures to the Project.toml `[deps]` section.

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [September 26, 2019, 10:05am UTC](https://discourse.julialang.org/t/ann-haml-jl-rubys-favourite-templating-language-comes-to-julia/29066/7 "2019-09-26T10:05:40Z")

</div>

Oops thanks for catching that. Fixed!
