Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partials do not work #196

Closed
tduccuong opened this issue Feb 14, 2020 · 6 comments
Closed

partials do not work #196

tduccuong opened this issue Feb 14, 2020 · 6 comments

Comments

@tduccuong
Copy link

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

@OvermindDL1
Copy link
Collaborator

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. :-)

@OvermindDL1
Copy link
Collaborator

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

@tduccuong
Copy link
Author

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

@OvermindDL1
Copy link
Collaborator

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. :-)

@tduccuong
Copy link
Author

yay! works now, thanks a lot 👍

@OvermindDL1
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants