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

Cohabitation with LiveView #185

Open
guidotripaldi opened this issue Mar 29, 2019 · 0 comments
Open

Cohabitation with LiveView #185

guidotripaldi opened this issue Mar 29, 2019 · 0 comments

Comments

@guidotripaldi
Copy link
Contributor

guidotripaldi commented Mar 29, 2019

Since LiveView is now public, probably the developers will try to use both libraries in the same app, but at this time it is not possible because Drab.Client.generate_drab_js/3 rises when it tries to get the controller module for a LV page, as :phoenix_controller is not present in the conn of a LiveView page.

Checking for the presence of :live_view_module in the conn parameters reveals if the page is suited or not for generating the drab js, for example:

  defp generate_drab_js(conn, connect?, assigns) do

    if !conn.assigns[:live_view_module] do
      controller = Phoenix.Controller.controller_module(conn)
      ...

This way both libraries can cohabit at the same time in the same app, using Drab only for pages based on Controllers/.eex templates (but not for LiveView pages because its js code will not be injected).

Edit:
The PR #192 solve this problem with a more general solution than the one initially proposed above

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

1 participant