Rename component to defcomponent
This commit is contained in:
parent
e1c54ff09d
commit
48c5eacf25
2 changed files with 8 additions and 8 deletions
|
@ -86,7 +86,7 @@ defmodule Dsl.Html do
|
||||||
|
|
||||||
defmacro partial(text), do: quote(do: text(unquote(text)))
|
defmacro partial(text), do: quote(do: text(unquote(text)))
|
||||||
|
|
||||||
defmacro component(name, do: block) do
|
defmacro defcomponent(name, do: block) do
|
||||||
quote do
|
quote do
|
||||||
defmacro unquote(name)(props \\ [])
|
defmacro unquote(name)(props \\ [])
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ defmodule Dsl.HtmlTest do
|
||||||
use Dsl
|
use Dsl
|
||||||
|
|
||||||
defmodule Component do
|
defmodule Component do
|
||||||
component :flex do
|
defcomponent :flex do
|
||||||
div(class: "flex")
|
div(class: "flex")
|
||||||
end
|
end
|
||||||
|
|
||||||
component :takes_children do
|
defcomponent :takes_children do
|
||||||
div do
|
div do
|
||||||
div(id: "static-child-1")
|
div(id: "static-child-1")
|
||||||
@children
|
@children
|
||||||
|
@ -15,7 +15,7 @@ defmodule Dsl.HtmlTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
component :arbitrary_code do
|
defcomponent :arbitrary_code do
|
||||||
num = 1..10 |> Enum.reduce(0, fn x, sum -> x + sum end)
|
num = 1..10 |> Enum.reduce(0, fn x, sum -> x + sum end)
|
||||||
|
|
||||||
div do
|
div do
|
||||||
|
@ -23,7 +23,7 @@ defmodule Dsl.HtmlTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
component :uses_conditionals do
|
defcomponent :uses_conditionals do
|
||||||
if @condition do
|
if @condition do
|
||||||
div()
|
div()
|
||||||
else
|
else
|
||||||
|
@ -31,7 +31,7 @@ defmodule Dsl.HtmlTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
component :arbitrary_data do
|
defcomponent :arbitrary_data do
|
||||||
for item <- @lists do
|
for item <- @lists do
|
||||||
div do
|
div do
|
||||||
text(inspect(item))
|
text(inspect(item))
|
||||||
|
@ -39,11 +39,11 @@ defmodule Dsl.HtmlTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
component :safe do
|
defcomponent :safe do
|
||||||
div()
|
div()
|
||||||
end
|
end
|
||||||
|
|
||||||
component :safe_with_prop do
|
defcomponent :safe_with_prop do
|
||||||
div id: "safe-with-prop" do
|
div id: "safe-with-prop" do
|
||||||
text(@prop)
|
text(@prop)
|
||||||
|
|
||||||
|
|
Reference in a new issue