Code Monkey home page Code Monkey logo

Comments (4)

lnr0626 avatar lnr0626 commented on September 6, 2024

Continuing the thread about live_patch/redirect not supporting containers inside the do block:

I mentioned I thought it was because they were using ~E under the hood instead of ~L; however after looking at the code it's because the method uses Phoenix.HTML.Tag.content_tag.
Relevant block show below:

  defp live_link(type, block_or_text, opts) do
    uri = Keyword.fetch!(opts, :to)
    replace = Keyword.get(opts, :replace, false)
    kind = if replace, do: "replace", else: "push"

    data = [phx_link: type, phx_link_state: kind]

    opts =
      opts
      |> Keyword.update(:data, data, &Keyword.merge(&1, data))
      |> Keyword.put(:href, uri)

    Phoenix.HTML.Tag.content_tag(:a, opts, do: block_or_text)
  end

from surface.

msaraiva avatar msaraiva commented on September 6, 2024

So I suppose it will only work when the content is simple markup even if you are not using Surface. I mean, if you try to use just LV and use <%= live_component SomeComponent, ... %> as the content, it won't work. Right?

If that's the case, this is also a LiveView issue and we have two options:

  1. Open an issue on the phoenix LV project to check why it doesn't accept it. It might be by design or due to some technical limitation. In either case, it would be nice to know if they intend to change this behaviour in the near future or not. I think since the component API is quite new and usually the content of those helpers a simple, users may have not faced this problem yet.

  2. Implement our own helpers without depending on content_tag.

I think choosing #2 will depend on the answer of #1.

from surface.

lnr0626 avatar lnr0626 commented on September 6, 2024

Yeah, live_component within live_patch/live_redirect fails with the same error message. I'll go ahead and post an issue over there.

I already have a live patch/live redirect component that doesn't use content_tag which I'd be happy to push up as a PR; though I understand if you want to hold off until we get feedback from the LV project

from surface.

msaraiva avatar msaraiva commented on September 6, 2024

I already have a live patch/live redirect component that doesn't use content_tag which I'd be happy to push up as a PR

Awesome! Feel free to submit a PR. We can replace the implementation later in case they update the original one.

from surface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.