Coder Social home page Coder Social logo

phx_tailwind_generators's People

Contributors

andreaseriksson avatar tannineo avatar wintermeyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

phx_tailwind_generators's Issues

How to activate the tailwind_error_tag/2 helper

In lib/mix/tasks/phx_gen_tailwind.ex line 200 the following code can be found:

defp error(field) do
  # ~s(<%= PhxTailwindGenerators.tailwind_error_tag f, #{inspect(field)} %>)
end

I don't know how to make PhxTailwindGenerators.tailwind_error_tag or better just tailwind_error_tag work. That's the reason why it is commented out. But I'd like to make it work.

The helper function is defined in lib/phx_tailwind_generators.ex but commented out because I don't know how to import ErrorHelpers and if this is the right file to host this function.

  # import ??????????????.ErrorHelpers

  # def tailwind_error_tag(form, field) do
  #   Enum.map(Keyword.get_values(form.errors, field), fn error ->
  #     content_tag(:p, translate_error(error),
  #       class: "mt-2 text-sm text-red-500",
  #       phx_feedback_for: input_name(form, field)
  #     )
  #   end)
  # end

Make tailwind_error_tag/2 available as a helper

Running mix phx.gen.tailwind Blog Post posts title body:text works fine. But when I do anything afterwards I get this error:

$ mix ecto.migrate
Compiling 18 files (.ex)
warning: undefined function tailwind_error_tag/2
  lib/example_shop_web/templates/post/form.html.eex:45


== Compilation error in file lib/example_shop_web/views/post_view.ex ==
** (CompileError) lib/example_shop_web/templates/post/form.html.eex:37: undefined function tailwind_error_tag/2
    (elixir 1.11.2) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
    (stdlib 3.11) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.11.2) lib/kernel/parallel_compiler.ex:314: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

I use the tailwind_error_tag/2 function as a helper in form.html.eex. But I have no idea how to actually copy it into the application of if I even have to copy it or if I can call it some other way.

I added the function into https://github.com/wintermeyer/phx_tailwind_generators/blob/main/lib/phx_tailwind_generators.ex

Here it is:

  def tailwind_error_tag(form, field) do
    Enum.map(Keyword.get_values(form.errors, field), fn error ->
      content_tag(:p, translate_error(error),
        class: "mt-2 text-sm text-red-500",
        phx_feedback_for: input_name(form, field)
      )
    end)
  end

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.