nurugger07 / calliope

An elixir haml parser
Apache License 2.0
198 stars 37 forks source link

Calliope chokes on functions that take a block. #64

Closed Qqwy closed 7 years ago

Qqwy commented 8 years ago

(This was first posted on the (phoenix_haml github project](https://github.com/chrismccord/phoenix_haml/issues/35), and there I was guided here)

First and foremost: How nice that there is a HAML-parser for Elixir! :-)

I have 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

link is a phoenix_html function that optionally takes a do: block as parameter. This way, in EEx, you can embed more complex html in your links.

However, this breaks the Calliope's 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.

smpallen99 commented 8 years ago

Yes, not supported at this time. You might try adding an explicit - end. Of course, pull requests are welcome :)

Sent from my iPhone

On May 21, 2016, at 3:41 PM, Qqwy notifications@github.com wrote:

(This was first posted on the (phoenix_haml github project](chrismccord/phoenix_haml#35), and there I was guided here)

First and foremost: How nice that there is a HAML-parser for Elixir! :-)

I have 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

link is a phoenix_html function that optionally takes a do: block as parameter. This way, in EEx, you can embed more complex html in your links.

However, this breaks the Calliope's 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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

Qqwy commented 8 years ago

Thank you!

I will use - end for now, and maybe create a pull-request once I understand the Calliope source.

It would be great if a note about this could be added to the readme, to prevent confusion of other people facing the same issue in the future.