wintermeyer / phx_tailwind_generators Goto Github PK
View Code? Open in Web Editor NEWScaffold Generator which uses TailwindCSS.
License: MIT License
Scaffold Generator which uses TailwindCSS.
License: MIT License
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
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
Using your README, I don't have success installing postcss-loader using your instructions:
$ npm install tailwindcss postcss autoprefixer postcss-loader --save-dev
The Pragmatic Studio instructions were slightly different. This worked for me:
$ npm install tailwindcss postcss autoprefixer [email protected] --save-dev
See https://pragmaticstudio.com/tutorials/adding-tailwind-css-to-phoenix
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.