grych / drab

Remote controlled frontend framework for Phoenix.

Home Page:https://tg.pl/drab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

partials do not work

tduccuong opened this issue · comments

Hi,
I have a bare minimum test Drab-powered app. In the index.html.drab I have

<%= render "navbar.html" %>

Then, next to index.html.drab I created navbar.html.drab with content

NavBar here

The compiler gives me this error:

== Compilation error in file lib/tgshop_web/views/cms_view.ex ==
** (FunctionClauseError) no function clause matching in :lists.flatten/1    
    
    The following arguments were given to :lists.flatten/1:
    
        # 1
        {:__block__, [], [{:=, [], [{:tmp1, [], Drab.Live.EExEngine}, ["{{{{@drab-partial:gm4dsnzxhaytioi}}}}"]]}, [{:tmp1, [], Drab.Live.EExEngine}, {:case, [generated: true], [{:render, [line: 1], ["navbar.html"]}, [do: [{:->, [generated: true], [[safe: {:data, [generated: true], Drab.Live.EExEngine}], {:data, [generated: true], Drab.Live.EExEngine}]}, {:->, [generated: true], [[{:when, [generated: true], [{:bin, [generated: true], Drab.Live.EExEngine}, {:is_binary, [generated: true, context: Drab.Live.EExEngine, import: Kernel], [{:bin, [generated: true], Drab.Live.EExEngine}]}]}], {{:., [generated: true], [{:__aliases__, [generated: true, alias: false], [:Plug, :HTML]}, :html_escape]}, [generated: true], [{:bin, [generated: true], Drab.Live.EExEngine}]}]}, {:->, [generated: true], [[{:other, [generated: true], Drab.Live.EExEngine}], {{:., [line: 1], [{:__aliases__, [line: 1, alias: false], [:Phoenix, :HTML, :Safe]}, :to_iodata]}, [line: 1], [{:other, [line: 1], Drab.Live.EExEngine}]}]}]]]}]]}
    
    (stdlib 3.11.2) lists.erl:616: :lists.flatten/1
    lib/drab/live/eex_engine.ex:118: Drab.Live.EExEngine.handle_body/1
    lib/drab/live/engine.ex:17: Drab.Live.Engine.compile/2
    (phoenix 1.4.13) lib/phoenix/template.ex:355: Phoenix.Template.compile/3
    (phoenix 1.4.13) lib/phoenix/template.ex:166: anonymous fn/4 in Phoenix.Template."MACRO-__before_compile__"/2
    (elixir 1.10.1) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix 1.4.13) expanding macro: Phoenix.Template.__before_compile__/1

As an excuse, I am using Drab and Phoenix for first time!
Thanks a lot

Ah I think it doesn't handle top-level text in a file. It assumes well formed HTML by default (that's how it decorates it for fast updates). Try wrapping the NavBar here with <span>NavBar here</span> or some other element as appropriate and see if that works? If it does then I may need to add some better error reporting. :-)

I think I might see the problem looking in the code as well, let me try to push a fix...

cool, pls tell me when u pushed. Just try with <div>NavBar here</div>, same error...

I just pushed it to git, can you try using the master github branch as a dependency and see if that fixes it? If not I'll keep looking. If it works then I can make a release. :-)

yay! works now, thanks a lot 👍

Awesome! Pushing a new release 0.10.4 now, expect it on hex momentarily. :-)