HAML parser has problems with phoenix_html `link do` helper
Qqwy opened this issue · comments
First and foremost: How nice that there is a HAML-parser for Elixir/Phoenix! :-)
Unfortunately, the following goes wrong:
This file (saved as templates/layout/menu.html.haml
)
%nav.ui.top.fixed.menu
.header.item
Cyclicash
.right.menu
=link to: login_path, class: "item" do
login
= link to: register_path, class: "item" do
register
breaks the HAML-parsing. Here is the stacktrace:
== Compilation error on file web/views/layout_view.ex ==
** (EEx.SyntaxError) web/templates/layout/menu.html.haml:11: unexpected end of string, expected a closing '<% end %>'
(eex) lib/eex/compiler.ex:68: EEx.Compiler.generate_buffer/4
(eex) lib/eex/compiler.ex:41: EEx.Compiler.generate_buffer/4
(phoenix) lib/phoenix/template.ex:321: Phoenix.Template.compile/2
(phoenix) lib/phoenix/template.ex:154: Phoenix.Template."-MACRO-__before_compile__/2-fun-0-"/3
(elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) expanding macro: Phoenix.Template.__before_compile__/1
web/views/layout_view.ex:1: Heads.LayoutView (module)
(elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8
I think it chokes on the optional block-passing.
phoenix_haml isn't a haml parser and it doesn't really do much. Your issue is with calliope and should be submitted in to that project https://github.com/nurugger07/calliope. However, I can tell you that calliope doesn't support that syntax so it may be a feature request rather than a bug report.
Actually, I believe you can do it like this:
%nav.ui.top.fixed.menu
.header.item
Cyclicash
.right.menu
=link to: login_path, class: "item" do
login
- end
= link to: register_path, class: "item" do
register
- end
You just need an explicit - end
on each block.
[Edit: I realized after commenting that the link above already provided this solution.]