Current section

17 Versions

Jump to

Compare versions

6 files changed
+310 additions
-134 deletions
  @@ -46,11 +46,11 @@ iex> Nitroux.div(html: p("hello world"))
46 46 Take this HTML as an example:
47 47
48 48 ```html
49 - <ul>
50 - <li class="tab-1">Tab1</li>
51 - <li class="tab-2">Tab2</li>
52 - <li class="tab-3">Tab3</li>
53 - </ul>
49 + <ul>
50 + <li class="tab-1">Tab1</li>
51 + <li class="tab-2">Tab2</li>
52 + <li class="tab-3">Tab3</li>
53 + </ul>
54 54 ```
55 55
56 56 We usually don't think of HTML as code, but if we were to treat it as such, would have to admit that this example does not adhere to the DRY (Don't Repeat Yourself) principle. Nitroux solves this problem by allowing us to think of HTML as code, while keeping our maintenance burden to the minimum. The above example becomes:
  @@ -78,7 +78,6 @@ Nitroux offers an alternative approach. Instead of reinventing HTML with a custo
78 78
79 79 Nitroux is an ideal choice for scenarios involving [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components), lightweight JavaScript frameworks like [Alpine JS](https://alpinejs.dev/) or [Stimulus](https://stimulus.hotwired.dev/), or comprehensive HTML/XML parsers like [Owl](https://odoo.github.io/owl/) or the now-deprecated [AngularJS](https://angularjs.org/). It simplifies the development process and promotes cleaner, more maintainable code that even novice frontend developers can maintain.
80 80
81 -
82 81 ## Installation
83 82
84 83 If [available in Hex](https://hex.pm/docs/publish), the package can be installed
  @@ -92,8 +91,6 @@ def deps do
92 91 end
93 92 ```
94 93
95 -
96 94 Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
97 95 and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
98 96 be found at <https://hexdocs.pm/nitroux>.
99 -
  @@ -1,19 +1,20 @@
1 - {<<"app">>,<<"nitroux">>}.
2 - {<<"build_tools">>,[<<"mix">>]}.
1 + {<<"links">>,[{<<"GitHub">>,<<"https://github.com/tolyo/nitroux">>}]}.
2 + {<<"name">>,<<"nitroux">>}.
3 + {<<"version">>,<<"0.3.3">>}.
3 4 {<<"description">>,<<"Nitrogen-like templates for your Plug applications">>}.
4 5 {<<"elixir">>,<<"~> 1.13">>}.
6 + {<<"app">>,<<"nitroux">>}.
5 7 {<<"files">>,
6 8 [<<"lib">>,<<"lib/nitroux.ex">>,<<"lib/nitroux">>,
7 - <<"lib/nitroux/html_tags.ex">>,<<"lib/nitroux/plug.ex">>,
9 + <<"lib/nitroux/html_tags.ex">>,<<"lib/nitroux/types">>,
10 + <<"lib/nitroux/types/global_attributes.ex">>,<<"lib/nitroux/plug.ex">>,
8 11 <<"lib/nitroux/utils.ex">>,<<".formatter.exs">>,<<"mix.exs">>,
9 12 <<"README.md">>,<<"LICENSE">>]}.
10 13 {<<"licenses">>,[<<"MIT License">>]}.
11 - {<<"links">>,[{<<"GitHub">>,<<"https://github.com/tolyo/nitroux">>}]}.
12 - {<<"name">>,<<"nitroux">>}.
13 14 {<<"requirements">>,
14 - [[{<<"app">>,<<"plug">>},
15 - {<<"name">>,<<"plug">>},
15 + [[{<<"name">>,<<"plug">>},
16 + {<<"app">>,<<"plug">>},
16 17 {<<"optional">>,false},
17 - {<<"repository">>,<<"hexpm">>},
18 - {<<"requirement">>,<<"~> 1.13">>}]]}.
19 - {<<"version">>,<<"0.3.2">>}.
18 + {<<"requirement">>,<<"~> 1.13">>},
19 + {<<"repository">>,<<"hexpm">>}]]}.
20 + {<<"build_tools">>,[<<"mix">>]}.
  @@ -1,342 +1,344 @@
1 1 defmodule Nitroux.HtmlTags do
2 + # AUTO GENERATED. DO NOT EDIT
3 +
2 4 defmacro __using__(_opts) do
3 5 quote do
4 6 import Nitroux.Utils
5 7
6 - @spec a(binary | maybe_improper_list | map) :: binary
8 + @spec a(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
7 9 def a(attrs), do: "a" |> tag(attrs)
8 10
9 - @spec abbr(binary | maybe_improper_list | map) :: binary
11 + @spec abbr(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
10 12 def abbr(attrs), do: "abbr" |> tag(attrs)
11 13
12 - @spec address(binary | maybe_improper_list | map) :: binary
14 + @spec address(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
13 15 def address(attrs), do: "address" |> tag(attrs)
14 16
15 - @spec area(binary | maybe_improper_list | map) :: binary
17 + @spec area(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
16 18 def area(attrs), do: "area" |> tag(attrs, false)
17 19
18 - @spec article(binary | maybe_improper_list | map) :: binary
20 + @spec article(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
19 21 def article(attrs), do: "article" |> tag(attrs)
20 22
21 - @spec aside(binary | maybe_improper_list | map) :: binary
23 + @spec aside(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
22 24 def aside(attrs), do: "aside" |> tag(attrs)
23 25
24 - @spec audio(binary | maybe_improper_list | map) :: binary
26 + @spec audio(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
25 27 def audio(attrs), do: "audio" |> tag(attrs)
26 28
27 - @spec b(binary | maybe_improper_list | map) :: binary
29 + @spec b(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
28 30 def b(attrs), do: "b" |> tag(attrs)
29 31
30 - @spec base(binary | maybe_improper_list | map) :: binary
32 + @spec base(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
31 33 def base(attrs), do: "base" |> tag(attrs, false)
32 34
33 - @spec bdi(binary | maybe_improper_list | map) :: binary
35 + @spec bdi(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
34 36 def bdi(attrs), do: "bdi" |> tag(attrs)
35 37
36 - @spec bdo(binary | maybe_improper_list | map) :: binary
38 + @spec bdo(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
37 39 def bdo(attrs), do: "bdo" |> tag(attrs)
38 40
39 - @spec blockquote(binary | maybe_improper_list | map) :: binary
41 + @spec blockquote(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
40 42 def blockquote(attrs), do: "blockquote" |> tag(attrs)
41 43
42 - @spec body(binary | maybe_improper_list | map) :: binary
44 + @spec body(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
43 45 def body(attrs), do: "body" |> tag(attrs)
44 46
45 - @spec br(binary | maybe_improper_list | map) :: binary
47 + @spec br(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
46 48 def br(attrs), do: "br" |> tag(attrs, false)
47 49
48 - @spec button(binary | maybe_improper_list | map) :: binary
50 + @spec button(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
49 51 def button(attrs), do: "button" |> tag(attrs)
50 52
51 - @spec canvas(binary | maybe_improper_list | map) :: binary
53 + @spec canvas(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
52 54 def canvas(attrs), do: "canvas" |> tag(attrs)
53 55
54 - @spec caption(binary | maybe_improper_list | map) :: binary
56 + @spec caption(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
55 57 def caption(attrs), do: "caption" |> tag(attrs)
56 58
57 - @spec cite(binary | maybe_improper_list | map) :: binary
59 + @spec cite(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
58 60 def cite(attrs), do: "cite" |> tag(attrs)
59 61
60 - @spec code(binary | maybe_improper_list | map) :: binary
62 + @spec code(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
61 63 def code(attrs), do: "code" |> tag(attrs)
62 64
63 - @spec col(binary | maybe_improper_list | map) :: binary
65 + @spec col(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
64 66 def col(attrs), do: "col" |> tag(attrs, false)
65 67
66 - @spec colgroup(binary | maybe_improper_list | map) :: binary
68 + @spec colgroup(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
67 69 def colgroup(attrs), do: "colgroup" |> tag(attrs)
68 70
69 - @spec data(binary | maybe_improper_list | map) :: binary
71 + @spec data(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
70 72 def data(attrs), do: "data" |> tag(attrs)
71 73
72 - @spec datalist(binary | maybe_improper_list | map) :: binary
74 + @spec datalist(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
73 75 def datalist(attrs), do: "datalist" |> tag(attrs)
74 76
75 - @spec dd(binary | maybe_improper_list | map) :: binary
77 + @spec dd(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
76 78 def dd(attrs), do: "dd" |> tag(attrs)
77 79
78 - @spec del(binary | maybe_improper_list | map) :: binary
80 + @spec del(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
79 81 def del(attrs), do: "del" |> tag(attrs)
80 82
81 - @spec details(binary | maybe_improper_list | map) :: binary
83 + @spec details(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
82 84 def details(attrs), do: "details" |> tag(attrs)
83 85
84 - @spec dfn(binary | maybe_improper_list | map) :: binary
86 + @spec dfn(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
85 87 def dfn(attrs), do: "dfn" |> tag(attrs)
86 88
87 - @spec dialog(binary | maybe_improper_list | map) :: binary
89 + @spec dialog(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
88 90 def dialog(attrs), do: "dialog" |> tag(attrs)
89 91
90 - @spec div(binary | maybe_improper_list | map) :: binary
92 + @spec div(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
91 93 def div(attrs), do: "div" |> tag(attrs)
92 94
93 - @spec dl(binary | maybe_improper_list | map) :: binary
95 + @spec dl(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
94 96 def dl(attrs), do: "dl" |> tag(attrs)
95 97
96 - @spec dt(binary | maybe_improper_list | map) :: binary
98 + @spec dt(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
97 99 def dt(attrs), do: "dt" |> tag(attrs)
98 100
99 - @spec em(binary | maybe_improper_list | map) :: binary
101 + @spec em(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
100 102 def em(attrs), do: "em" |> tag(attrs)
101 103
102 - @spec embed(binary | maybe_improper_list | map) :: binary
104 + @spec embed(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
103 105 def embed(attrs), do: "embed" |> tag(attrs, false)
104 106
105 - @spec fieldset(binary | maybe_improper_list | map) :: binary
107 + @spec fieldset(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
106 108 def fieldset(attrs), do: "fieldset" |> tag(attrs)
107 109
108 - @spec figcaption(binary | maybe_improper_list | map) :: binary
110 + @spec figcaption(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
109 111 def figcaption(attrs), do: "figcaption" |> tag(attrs)
110 112
111 - @spec figure(binary | maybe_improper_list | map) :: binary
113 + @spec figure(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
112 114 def figure(attrs), do: "figure" |> tag(attrs)
113 115
114 - @spec footer(binary | maybe_improper_list | map) :: binary
116 + @spec footer(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
115 117 def footer(attrs), do: "footer" |> tag(attrs)
116 118
117 - @spec form(binary | maybe_improper_list | map) :: binary
119 + @spec form(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
118 120 def form(attrs), do: "form" |> tag(attrs)
119 121
120 - @spec h1(binary | maybe_improper_list | map) :: binary
122 + @spec h1(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
121 123 def h1(attrs), do: "h1" |> tag(attrs)
122 124
123 - @spec h2(binary | maybe_improper_list | map) :: binary
125 + @spec h2(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
124 126 def h2(attrs), do: "h2" |> tag(attrs)
125 127
126 - @spec h3(binary | maybe_improper_list | map) :: binary
128 + @spec h3(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
127 129 def h3(attrs), do: "h3" |> tag(attrs)
128 130
129 - @spec h4(binary | maybe_improper_list | map) :: binary
131 + @spec h4(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
130 132 def h4(attrs), do: "h4" |> tag(attrs)
131 133
132 - @spec h5(binary | maybe_improper_list | map) :: binary
134 + @spec h5(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
133 135 def h5(attrs), do: "h5" |> tag(attrs)
134 136
135 - @spec h6(binary | maybe_improper_list | map) :: binary
137 + @spec h6(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
136 138 def h6(attrs), do: "h6" |> tag(attrs)
137 139
138 - @spec head(binary | maybe_improper_list | map) :: binary
140 + @spec head(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
139 141 def head(attrs), do: "head" |> tag(attrs)
140 142
141 - @spec header(binary | maybe_improper_list | map) :: binary
143 + @spec header(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
142 144 def header(attrs), do: "header" |> tag(attrs)
143 145
144 - @spec hgroup(binary | maybe_improper_list | map) :: binary
146 + @spec hgroup(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
145 147 def hgroup(attrs), do: "hgroup" |> tag(attrs)
146 148
147 - @spec hr(binary | maybe_improper_list | map) :: binary
149 + @spec hr(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
148 150 def hr(attrs), do: "hr" |> tag(attrs, false)
149 151
150 - @spec html(binary | maybe_improper_list | map) :: binary
152 + @spec html(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
151 153 def html(attrs), do: "html" |> tag(attrs)
152 154
153 - @spec i(binary | maybe_improper_list | map) :: binary
155 + @spec i(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
154 156 def i(attrs), do: "i" |> tag(attrs)
155 157
156 - @spec iframe(binary | maybe_improper_list | map) :: binary
158 + @spec iframe(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
157 159 def iframe(attrs), do: "iframe" |> tag(attrs)
158 160
159 - @spec img(binary | maybe_improper_list | map) :: binary
161 + @spec img(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
160 162 def img(attrs), do: "img" |> tag(attrs, false)
161 163
162 - @spec input(binary | maybe_improper_list | map) :: binary
164 + @spec input(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
163 165 def input(attrs), do: "input" |> tag(attrs, false)
164 166
165 - @spec ins(binary | maybe_improper_list | map) :: binary
167 + @spec ins(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
166 168 def ins(attrs), do: "ins" |> tag(attrs)
167 169
168 - @spec kbd(binary | maybe_improper_list | map) :: binary
170 + @spec kbd(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
169 171 def kbd(attrs), do: "kbd" |> tag(attrs)
170 172
171 - @spec label(binary | maybe_improper_list | map) :: binary
173 + @spec label(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
172 174 def label(attrs), do: "label" |> tag(attrs)
173 175
174 - @spec legend(binary | maybe_improper_list | map) :: binary
176 + @spec legend(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
175 177 def legend(attrs), do: "legend" |> tag(attrs)
176 178
177 - @spec li(binary | maybe_improper_list | map) :: binary
179 + @spec li(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
178 180 def li(attrs), do: "li" |> tag(attrs)
179 181
180 - @spec link(binary | maybe_improper_list | map) :: binary
182 + @spec link(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
181 183 def link(attrs), do: "link" |> tag(attrs, false)
182 184
183 - @spec main(binary | maybe_improper_list | map) :: binary
185 + @spec main(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
184 186 def main(attrs), do: "main" |> tag(attrs)
185 187
186 - @spec map(binary | maybe_improper_list | map) :: binary
188 + @spec map(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
187 189 def map(attrs), do: "map" |> tag(attrs)
188 190
189 - @spec mark(binary | maybe_improper_list | map) :: binary
191 + @spec mark(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
190 192 def mark(attrs), do: "mark" |> tag(attrs)
191 193
192 - @spec menu(binary | maybe_improper_list | map) :: binary
194 + @spec menu(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
193 195 def menu(attrs), do: "menu" |> tag(attrs)
194 196
195 - @spec meta(binary | maybe_improper_list | map) :: binary
197 + @spec meta(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
196 198 def meta(attrs), do: "meta" |> tag(attrs, false)
197 199
198 - @spec meter(binary | maybe_improper_list | map) :: binary
200 + @spec meter(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
199 201 def meter(attrs), do: "meter" |> tag(attrs)
200 202
201 - @spec nav(binary | maybe_improper_list | map) :: binary
203 + @spec nav(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
202 204 def nav(attrs), do: "nav" |> tag(attrs)
203 205
204 - @spec noscript(binary | maybe_improper_list | map) :: binary
206 + @spec noscript(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
205 207 def noscript(attrs), do: "noscript" |> tag(attrs)
206 208
207 - @spec object(binary | maybe_improper_list | map) :: binary
209 + @spec object(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
208 210 def object(attrs), do: "object" |> tag(attrs)
209 211
210 - @spec ol(binary | maybe_improper_list | map) :: binary
212 + @spec ol(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
211 213 def ol(attrs), do: "ol" |> tag(attrs)
212 214
213 - @spec optgroup(binary | maybe_improper_list | map) :: binary
215 + @spec optgroup(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
214 216 def optgroup(attrs), do: "optgroup" |> tag(attrs)
215 217
216 - @spec option(binary | maybe_improper_list | map) :: binary
218 + @spec option(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
217 219 def option(attrs), do: "option" |> tag(attrs)
218 220
219 - @spec output(binary | maybe_improper_list | map) :: binary
221 + @spec output(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
220 222 def output(attrs), do: "output" |> tag(attrs)
221 223
222 - @spec p(binary | maybe_improper_list | map) :: binary
224 + @spec p(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
223 225 def p(attrs), do: "p" |> tag(attrs)
224 226
225 - @spec picture(binary | maybe_improper_list | map) :: binary
227 + @spec picture(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
226 228 def picture(attrs), do: "picture" |> tag(attrs)
227 229
228 - @spec pre(binary | maybe_improper_list | map) :: binary
230 + @spec pre(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
229 231 def pre(attrs), do: "pre" |> tag(attrs)
230 232
231 - @spec progress(binary | maybe_improper_list | map) :: binary
233 + @spec progress(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
232 234 def progress(attrs), do: "progress" |> tag(attrs)
233 235
234 - @spec q(binary | maybe_improper_list | map) :: binary
236 + @spec q(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
235 237 def q(attrs), do: "q" |> tag(attrs)
236 238
237 - @spec rp(binary | maybe_improper_list | map) :: binary
239 + @spec rp(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
238 240 def rp(attrs), do: "rp" |> tag(attrs)
239 241
240 - @spec rt(binary | maybe_improper_list | map) :: binary
242 + @spec rt(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
241 243 def rt(attrs), do: "rt" |> tag(attrs)
242 244
243 - @spec ruby(binary | maybe_improper_list | map) :: binary
245 + @spec ruby(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
244 246 def ruby(attrs), do: "ruby" |> tag(attrs)
245 247
246 - @spec s(binary | maybe_improper_list | map) :: binary
248 + @spec s(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
247 249 def s(attrs), do: "s" |> tag(attrs)
248 250
249 - @spec samp(binary | maybe_improper_list | map) :: binary
251 + @spec samp(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
250 252 def samp(attrs), do: "samp" |> tag(attrs)
251 253
252 - @spec script(binary | maybe_improper_list | map) :: binary
254 + @spec script(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
253 255 def script(attrs), do: "script" |> tag(attrs)
254 256
255 - @spec search(binary | maybe_improper_list | map) :: binary
257 + @spec search(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
256 258 def search(attrs), do: "search" |> tag(attrs)
257 259
258 - @spec section(binary | maybe_improper_list | map) :: binary
260 + @spec section(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
259 261 def section(attrs), do: "section" |> tag(attrs)
260 262
261 - @spec select(binary | maybe_improper_list | map) :: binary
263 + @spec select(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
262 264 def select(attrs), do: "select" |> tag(attrs)
263 265
264 - @spec slot(binary | maybe_improper_list | map) :: binary
266 + @spec slot(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
265 267 def slot(attrs), do: "slot" |> tag(attrs)
266 268
267 - @spec small(binary | maybe_improper_list | map) :: binary
269 + @spec small(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
268 270 def small(attrs), do: "small" |> tag(attrs)
269 271
270 - @spec source(binary | maybe_improper_list | map) :: binary
272 + @spec source(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
271 273 def source(attrs), do: "source" |> tag(attrs, false)
272 274
273 - @spec span(binary | maybe_improper_list | map) :: binary
275 + @spec span(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
274 276 def span(attrs), do: "span" |> tag(attrs)
275 277
276 - @spec strong(binary | maybe_improper_list | map) :: binary
278 + @spec strong(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
277 279 def strong(attrs), do: "strong" |> tag(attrs)
278 280
279 - @spec style(binary | maybe_improper_list | map) :: binary
281 + @spec style(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
280 282 def style(attrs), do: "style" |> tag(attrs)
281 283
282 - @spec sub(binary | maybe_improper_list | map) :: binary
284 + @spec sub(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
283 285 def sub(attrs), do: "sub" |> tag(attrs)
284 286
285 - @spec summary(binary | maybe_improper_list | map) :: binary
287 + @spec summary(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
286 288 def summary(attrs), do: "summary" |> tag(attrs)
287 289
288 - @spec sup(binary | maybe_improper_list | map) :: binary
290 + @spec sup(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
289 291 def sup(attrs), do: "sup" |> tag(attrs)
290 292
291 - @spec table(binary | maybe_improper_list | map) :: binary
293 + @spec table(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
292 294 def table(attrs), do: "table" |> tag(attrs)
293 295
294 - @spec tbody(binary | maybe_improper_list | map) :: binary
296 + @spec tbody(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
295 297 def tbody(attrs), do: "tbody" |> tag(attrs)
296 298
297 - @spec td(binary | maybe_improper_list | map) :: binary
299 + @spec td(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
298 300 def td(attrs), do: "td" |> tag(attrs)
299 301
300 - @spec template(binary | maybe_improper_list | map) :: binary
302 + @spec template(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
301 303 def template(attrs), do: "template" |> tag(attrs)
302 304
303 - @spec textarea(binary | maybe_improper_list | map) :: binary
305 + @spec textarea(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
304 306 def textarea(attrs), do: "textarea" |> tag(attrs)
305 307
306 - @spec tfoot(binary | maybe_improper_list | map) :: binary
308 + @spec tfoot(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
307 309 def tfoot(attrs), do: "tfoot" |> tag(attrs)
308 310
309 - @spec th(binary | maybe_improper_list | map) :: binary
311 + @spec th(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
310 312 def th(attrs), do: "th" |> tag(attrs)
311 313
312 - @spec thead(binary | maybe_improper_list | map) :: binary
314 + @spec thead(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
313 315 def thead(attrs), do: "thead" |> tag(attrs)
314 316
315 - @spec time(binary | maybe_improper_list | map) :: binary
317 + @spec time(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
316 318 def time(attrs), do: "time" |> tag(attrs)
317 319
318 - @spec title(binary | maybe_improper_list | map) :: binary
320 + @spec title(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
319 321 def title(attrs), do: "title" |> tag(attrs)
320 322
321 - @spec tr(binary | maybe_improper_list | map) :: binary
323 + @spec tr(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
322 324 def tr(attrs), do: "tr" |> tag(attrs)
323 325
324 - @spec track(binary | maybe_improper_list | map) :: binary
326 + @spec track(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
325 327 def track(attrs), do: "track" |> tag(attrs, false)
326 328
327 - @spec u(binary | maybe_improper_list | map) :: binary
329 + @spec u(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
328 330 def u(attrs), do: "u" |> tag(attrs)
329 331
330 - @spec ul(binary | maybe_improper_list | map) :: binary
332 + @spec ul(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
331 333 def ul(attrs), do: "ul" |> tag(attrs)
332 334
333 - @spec var(binary | maybe_improper_list | map) :: binary
335 + @spec var(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
334 336 def var(attrs), do: "var" |> tag(attrs)
335 337
336 - @spec video(binary | maybe_improper_list | map) :: binary
338 + @spec video(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
337 339 def video(attrs), do: "video" |> tag(attrs)
338 340
339 - @spec wbr(binary | maybe_improper_list | map) :: binary
341 + @spec wbr(String.t() | Nitroux.Types.GlobalAttributes.t()) :: binary
340 342 def wbr(attrs), do: "wbr" |> tag(attrs, false)
341 343 end
342 344 end
  @@ -0,0 +1,174 @@
1 + defmodule Nitroux.Types.GlobalAttributes do
2 + # AUTO GENERATED DO NOT EDIT
3 +
4 + @type t :: [
5 + accesskey: accesskey,
6 + autocapitalize: autocapitalize,
7 + autofocus: autofocus,
8 + class: class,
9 + contenteditable: contenteditable,
10 + dir: dir,
11 + draggable: draggable,
12 + enterkeyhint: enterkeyhint,
13 + exportparts: exportparts,
14 + hidden: hidden,
15 + id: id,
16 + inert: inert,
17 + inputmode: inputmode,
18 + is: is,
19 + itemid: itemid,
20 + itemprop: itemprop,
21 + itemref: itemref,
22 + itemscope: itemscope,
23 + itemtype: itemtype,
24 + lang: lang,
25 + nonce: nonce,
26 + part: part,
27 + slot: slot,
28 + spellcheck: spellcheck,
29 + style: style,
30 + tabindex: tabindex,
31 + title: title,
32 + translate: translate
33 + ]
34 +
35 + @typedoc """
36 + Provides a hint for generating a keyboard shortcut for the current element
37 + """
38 + @type accesskey :: String.t()
39 +
40 + @typedoc """
41 + Controls whether and how text input is automatically capitalized as it is entered/edited by the user
42 + """
43 + @type autocapitalize :: String.t()
44 +
45 + @typedoc """
46 + Indicates that an element should be focused on page load, or when the <dialog> that it is part of is displayed
47 + """
48 + @type autofocus :: bool
49 +
50 + @typedoc """
51 + A space-separated list of the case-sensitive classes of the element
52 + """
53 + @type class :: String.t()
54 +
55 + @typedoc """
56 + Indicates if the element should be editable by the user
57 + """
58 + @type contenteditable :: String.t()
59 +
60 + @typedoc """
61 + Indicates the directionality of the element's text
62 + """
63 + @type dir :: String.t()
64 +
65 + @typedoc """
66 + Indicates whether the element can be dragged, either with native browser behavior or the HTML Drag and Drop API.
67 + """
68 + @type draggable :: bool
69 +
70 + @typedoc """
71 + Defines what action label (or icon) to present for the enter key on virtual keyboards
72 + """
73 + @type enterkeyhint :: String.t()
74 +
75 + @typedoc """
76 + The exportparts global attribute allows you to select and style elements existing in nested shadow trees, by exporting their part names
77 + """
78 + @type exportparts :: String.t()
79 +
80 + @typedoc """
81 + Indicates that the browser should not render the contents of the element
82 + """
83 + @type hidden :: String.t()
84 +
85 + @typedoc """
86 + Defines an identifier (ID) which must be unique in the whole document
87 + """
88 + @type id :: String.t()
89 +
90 + @typedoc """
91 + indicating that the browser will ignore the element
92 + """
93 + @type inert :: bool
94 +
95 + @typedoc """
96 + hints at the type of data that might be entered by the user while editing the element or its contents
97 + """
98 + @type inputmode :: String.t()
99 +
100 + @typedoc """
101 + allows you to specify that a standard HTML element should behave like a defined custom built-in element
102 + """
103 + @type is :: String.t()
104 +
105 + @typedoc """
106 + The itemid global attribute provides microdata in the form of a unique, global identifier of an item
107 + """
108 + @type itemid :: String.t()
109 +
110 + @typedoc """
111 + The itemprop global attribute is used to add properties to an item
112 + """
113 + @type itemprop :: String.t()
114 +
115 + @typedoc """
116 + Properties that are not descendants of an element with the itemscope attribute can be associated with an item using the global attribute itemref
117 + """
118 + @type itemref :: String.t()
119 +
120 + @typedoc """
121 + itemscope is a boolean global attribute that defines the scope of associated metadata
122 + """
123 + @type itemscope :: String.t()
124 +
125 + @typedoc """
126 + The global attribute itemtype specifies the URL of the vocabulary that will be used to define itemprop's (item properties) in the data structure
127 + """
128 + @type itemtype :: String.t()
129 +
130 + @typedoc """
131 + The lang global attribute helps define the language of an element: the language that non-editable elements are written in, or the language that the editable elements should be written in by the user
132 + """
133 + @type lang :: String.t()
134 +
135 + @typedoc """
136 + The nonce global attribute is a content attribute defining a cryptographic nonce ("number used once") which can be used by Content Security Policy to determine whether or not a given fetch will be allowed to proceed for a given element
137 + """
138 + @type nonce :: String.t()
139 +
140 + @typedoc """
141 + The part global attribute contains a space-separated list of the part names of the element
142 + """
143 + @type part :: String.t()
144 +
145 + @typedoc """
146 + The slot global attribute assigns a slot in a shadow DOM shadow tree to an element: An element with a slot attribute is assigned to the slot created by the <slot> element whose name attribute's value matches that slot attribute's value
147 + """
148 + @type slot :: String.t()
149 +
150 + @typedoc """
151 + The spellcheck global attribute is an enumerated attribute that defines whether the element may be checked for spelling errors
152 + """
153 + @type spellcheck :: String.t()
154 +
155 + @typedoc """
156 + The style global attribute contains CSS styling declarations to be applied to the element
157 + """
158 + @type style :: String.t()
159 +
160 + @typedoc """
161 + The tabindex global attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key, hence the name) and determine their relative ordering for sequential focus navigation
162 + """
163 + @type tabindex :: bool
164 +
165 + @typedoc """
166 + The title global attribute contains text representing advisory information related to the element it belongs to
167 + """
168 + @type title :: String.t()
169 +
170 + @typedoc """
171 + The translate global attribute is an enumerated attribute that is used to specify whether an element's translatable attribute values and its Text node children should be translated when the page is localized, or whether to leave them unchanged
172 + """
173 + @type translate :: bool
174 + end
  @@ -1,11 +1,13 @@
1 1 defmodule Nitroux.Utils do
2 + @type tag :: String.t()
3 + @spec tag(any, Nitroux.Types.GlobalAttributes.t() | [tag] | tag, any) :: <<_::24, _::_*8>>
2 4 @doc """
3 5 Generates dynamic open and closing tags around content
4 6 iex> Nitroux.Utils.tag("div", ["hello", " ", "world"])
5 7 "<div>hello world</div>"
6 8
7 9 Nitroux.Utils.tag("div", [])
8 - "<div>hello world</div>"
10 + "<div></div>"
9 11
10 12 Nitroux.Utils.tag("div", [html: "hello world"])
11 13 "<div>hello world</div>"
  @@ -15,12 +17,12 @@ defmodule Nitroux.Utils do
15 17 """
16 18 def tag(name, attrs, container \\ true)
17 19 def tag(name, attrs, false), do: "<#{name}#{add_attributes(attrs)}/>"
18 -
20 + def tag(name, [], _container), do: name |> tag("", true)
19 21 def tag(name, [{_, _} | _t] = keywordlist, _container),
20 22 do: "<#{name}#{add_attributes(keywordlist)}>#{Keyword.get(keywordlist, :html, "")}</#{name}>"
21 23
22 24 def tag(name, [_h | _t] = list, _container), do: name |> tag(html: Enum.join(list))
23 - def tag(name, [], _container), do: name |> tag([], true)
25 +
24 26 def tag(name, text, _) when is_binary(text), do: "<#{name}>#{text}</#{name}>"
25 27
26 28 defp add_attributes(attrs) do
Loading more files…