From 7f63b8b814d57c9bebedc9a490dd5a3452330879 Mon Sep 17 00:00:00 2001 From: Anatoly Ostrovsky Date: Wed, 22 Nov 2023 18:33:01 +0200 Subject: [PATCH] Test --- lib/nitroux/utils.ex | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/nitroux/utils.ex b/lib/nitroux/utils.ex index fcaad2c..605666b 100644 --- a/lib/nitroux/utils.ex +++ b/lib/nitroux/utils.ex @@ -1,19 +1,17 @@ defmodule Nitroux.Utils do @type tag :: String.t() - @spec tag(any, Nitroux.Types.GlobalAttributes.t() | [tag] | tag, any) :: tag() + @spec tag(any, Nitroux.Types.GlobalAttributes.t() | [tag] | tag, boolean()) :: tag() @doc """ - Generates dynamic open and closing tags around content - iex> Nitroux.Utils.tag("div", ["hello", " ", "world"]) - "
hello world
" + Generates dynamic open and closing tags around content + iex> Nitroux.Utils.tag("div", []) + "
" - Nitroux.Utils.tag("div", []) - "
" + iex> Nitroux.Utils.tag("div", ["hello world"]) + "
hello world
" - Nitroux.Utils.tag("div", [html: "hello world"]) - "
hello world
" + iex> Nitroux.Utils.tag("div", ["hello", " ", "world"]) + "
hello world
" - Nitroux.Utils.tag("div", [class: "test", html: "hello world"]) - "
hello world
" """ def tag(name, attrs, container \\ true) def tag(name, attrs, false), do: "<#{name}#{add_attributes(attrs)}/>" @@ -23,7 +21,6 @@ defmodule Nitroux.Utils do do: "<#{name}#{add_attributes(keywordlist)}>#{Keyword.get(keywordlist, :html, "")}" def tag(name, [_h | _t] = list, _container), do: name |> tag(html: Enum.join(list)) - def tag(name, text, _) when is_binary(text), do: "<#{name}>#{text}" defp add_attributes(attrs) do