fun_html 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 13b40e387a0918c00e2108500089a3d836fe249735a4534c42c41cb2a8332d47
4
+ data.tar.gz: 22996090296b7f7446b1daa362a1a7c519d1dfa3cd5e5c85d44f355a59db91d6
5
+ SHA512:
6
+ metadata.gz: 2adca4a4c6d9a45a0f6a7471b4d4ed792979cd7dc4d1a989c36b1cb704d3abf3c90b0a2898e36a8f050e91f93165103ecb01a213c72b4cac3dcfd69ab1e63037
7
+ data.tar.gz: 0e619b46976d8a7debd87fab5872492a49c63026ffa408a1529182ee62f2d209e6cc67831ab42a0265a8489c25880c28431d68e688b6bb7fb7cf0ec4654d4d2b
@@ -0,0 +1,191 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FunHtml
4
+ # HTML attributes autogenerated, do not edit
5
+ module AttributeDefinitions
6
+ # Specifies file types browser will accept
7
+ def accept(value) = write(' accept="', value)
8
+ # Character encodings used for form submission
9
+ def accept_charset(value) = write(' accept-charset="', value)
10
+ # Keyboard shortcut to access element
11
+ def accesskey(value) = write(' accesskey="', value)
12
+ # URL where form data is submitted
13
+ def action(value) = write(' action="', value)
14
+ # Alignment of content
15
+ def align(value) = write(' align="', value)
16
+ # Alternative text for images
17
+ def alt(value) = write(' alt="', value)
18
+ # Script should execute asynchronously
19
+ def async(state = true) = write_empty(' async', state)
20
+ # Form/input autocompletion
21
+ def autocomplete(value) = write(' autocomplete="', value)
22
+ # Element should be focused on page load
23
+ def autofocus(state = true) = write_empty(' autofocus', state)
24
+ # Media will start playing automatically
25
+ def autoplay(state = true) = write_empty(' autoplay', state)
26
+ # Background color of element
27
+ def bgcolor(value) = write(' bgcolor="', value)
28
+ # Border width in pixels
29
+ def border(value) = write(' border="', value)
30
+ # Character encoding of document
31
+ def charset(value) = write(' charset="', value)
32
+ # Whether checkbox/radio button is selected
33
+ def checked(state = true) = write_empty(' checked', state)
34
+ # CSS class name(s) for styling
35
+ def klass(value) = write(' class="', value)
36
+ # Number of columns in textarea
37
+ def cols(value) = write(' cols="', value)
38
+ # Number of columns a cell spans
39
+ def colspan(value) = write(' colspan="', value)
40
+ # Content for meta tags
41
+ def content(value) = write(' content="', value)
42
+ # Whether content is editable
43
+ def contenteditable(value) = write(' contenteditable="', value)
44
+ # Show media playback controls
45
+ def controls(state = true) = write_empty(' controls', state)
46
+ # Coordinates for image maps
47
+ def coords(value) = write(' coords="', value)
48
+ # Custom data attributes
49
+ def data(value) = write(' data="', value)
50
+ # Date/time of element content
51
+ def datetime(value) = write(' datetime="', value)
52
+ # Default track for media
53
+ def default(state = true) = write_empty(' default', state)
54
+ # Script should execute after parsing
55
+ def defer(state = true) = write_empty(' defer', state)
56
+ # Text direction
57
+ def dir(value) = write(' dir="', value)
58
+ # Element is disabled
59
+ def disabled(state = true) = write_empty(' disabled', state)
60
+ # Resource should be downloaded
61
+ def download(value) = write(' download="', value)
62
+ # Element can be dragged
63
+ def draggable(value) = write(' draggable="', value)
64
+ # Form data encoding for submission
65
+ def enctype(value) = write(' enctype="', value)
66
+ # Associates label with form control
67
+ def for(value) = write(' for="', value)
68
+ # Form the element belongs to
69
+ def form(value) = write(' form="', value)
70
+ # URL for form submission
71
+ def formaction(value) = write(' formaction="', value)
72
+ # Related header cells for data cell
73
+ def headers(value) = write(' headers="', value)
74
+ # Height of element
75
+ def height(value) = write(' height="', value)
76
+ # Element is not displayed
77
+ def hidden(state = true) = write_empty(' hidden', state)
78
+ # Upper range of meter
79
+ def high(value) = write(' high="', value)
80
+ # URL of linked resource
81
+ def href(value) = write(' href="', value)
82
+ # Language of linked resource
83
+ def hreflang(value) = write(' hreflang="', value)
84
+ # Unique identifier for element
85
+ def id(value) = write(' id="', value)
86
+ # Subresource integrity hash
87
+ def integrity(value) = write(' integrity="', value)
88
+ # Image is server-side image map
89
+ def ismap(state = true) = write_empty(' ismap', state)
90
+ # Type of text track
91
+ def kind(value) = write(' kind="', value)
92
+ # Label for form control/option
93
+ def label(value) = write(' label="', value)
94
+ # Language of element content
95
+ def lang(value) = write(' lang="', value)
96
+ # Links input to datalist options
97
+ def list(value) = write(' list="', value)
98
+ # Media will replay when finished
99
+ def loop(state = true) = write_empty(' loop', state)
100
+ # Lower range of meter
101
+ def low(value) = write(' low="', value)
102
+ # Maximum allowed value
103
+ def max(value) = write(' max="', value)
104
+ # Maximum length of input
105
+ def maxlength(value) = write(' maxlength="', value)
106
+ # Media type for resource
107
+ def media(value) = write(' media="', value)
108
+ # HTTP method for form submission
109
+ def method(value) = write(' method="', value)
110
+ # Minimum allowed value
111
+ def min(value) = write(' min="', value)
112
+ # Multiple values can be selected
113
+ def multiple(state = true) = write_empty(' multiple', state)
114
+ # Media is muted by default
115
+ def muted(state = true) = write_empty(' muted', state)
116
+ # Name of form control
117
+ def name(value) = write(' name="', value)
118
+ # Form validation is skipped
119
+ def novalidate(state = true) = write_empty(' novalidate', state)
120
+ # Details element is expanded
121
+ def open(state = true) = write_empty(' open', state)
122
+ # Optimal value for meter
123
+ def optimum(value) = write(' optimum="', value)
124
+ # Regular expression pattern
125
+ def pattern(value) = write(' pattern="', value)
126
+ # Hint text for input field
127
+ def placeholder(value) = write(' placeholder="', value)
128
+ # Preview image for video
129
+ def poster(value) = write(' poster="', value)
130
+ # How media should be loaded
131
+ def preload(value) = write(' preload="', value)
132
+ # Input field cannot be modified
133
+ def readonly(state = true) = write_empty(' readonly', state)
134
+ # Relationship of linked resource
135
+ def rel(value) = write(' rel="', value)
136
+ # Input must be filled out
137
+ def required(state = true) = write_empty(' required', state)
138
+ # List is numbered in reverse
139
+ def reversed(state = true) = write_empty(' reversed', state)
140
+ # Number of rows in textarea
141
+ def rows(value) = write(' rows="', value)
142
+ # Number of rows a cell spans
143
+ def rowspan(value) = write(' rowspan="', value)
144
+ # Security rules for iframe
145
+ def sandbox(value) = write(' sandbox="', value)
146
+ # Cells header element relates to
147
+ def scope(value) = write(' scope="', value)
148
+ # Option is pre-selected
149
+ def selected(state = true) = write_empty(' selected', state)
150
+ # Shape of image map area
151
+ def shape(value) = write(' shape="', value)
152
+ # Size of input/select control
153
+ def size(value) = write(' size="', value)
154
+ # Image sizes for different layouts
155
+ def sizes(value) = write(' sizes="', value)
156
+ # Element should be spellchecked
157
+ def spellcheck(value) = write(' spellcheck="', value)
158
+ # URL of resource
159
+ def src(value) = write(' src="', value)
160
+ # Content for inline frame
161
+ def srcdoc(value) = write(' srcdoc="', value)
162
+ # Language of text track
163
+ def srclang(value) = write(' srclang="', value)
164
+ # Images to use in different situations
165
+ def srcset(value) = write(' srcset="', value)
166
+ # Starting number for ordered list
167
+ def start(value) = write(' start="', value)
168
+ # Increment for numeric input
169
+ def step(value) = write(' step="', value)
170
+ # Inline CSS styles
171
+ def style(value) = write(' style="', value)
172
+ # Position in tab order
173
+ def tabindex(value) = write(' tabindex="', value)
174
+ # Where to open linked document
175
+ def target(value) = write(' target="', value)
176
+ # Advisory information about element
177
+ def title(value) = write(' title="', value)
178
+ # Whether to translate content
179
+ def translate(value) = write(' translate="', value)
180
+ # Type of element or input
181
+ def type(value) = write(' type="', value)
182
+ # Image map to use
183
+ def usemap(value) = write(' usemap="', value)
184
+ # Value of form control
185
+ def value(value) = write(' value="', value)
186
+ # Width of element
187
+ def width(value) = write(' width="', value)
188
+ # How text wraps in textarea
189
+ def wrap(value) = write(' wrap="', value)
190
+ end
191
+ end
@@ -0,0 +1,796 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FunHtml
4
+ # HTML nodes autogenerated, do not edit
5
+ module NodeDefinitions
6
+ module HTMLHtmlElement
7
+ def html(attributes = nil, &elements)
8
+ write('<html', '</html>', attributes, &elements)
9
+ end
10
+ end
11
+
12
+ module HTMLHeadElement
13
+ def head(attributes = nil, &elements)
14
+ write('<head', '</head>', attributes, &elements)
15
+ end
16
+ end
17
+
18
+ module HTMLTitleElement
19
+ def title(attributes = nil, &elements)
20
+ write('<title', '</title>', attributes, &elements)
21
+ end
22
+ end
23
+
24
+ module HTMLBaseElement
25
+ def base(attributes = nil)
26
+ # no child elements allowed and no closing tag
27
+ write('<base', '>', attributes)
28
+ end
29
+ end
30
+
31
+ module HTMLLinkElement
32
+ def link(attributes = nil)
33
+ # no child elements allowed and no closing tag
34
+ write('<link', '>', attributes)
35
+ end
36
+ end
37
+
38
+ module HTMLMetaElement
39
+ def meta(attributes = nil)
40
+ # no child elements allowed and no closing tag
41
+ write('<meta', '>', attributes)
42
+ end
43
+ end
44
+
45
+ module HTMLStyleElement
46
+ def style(attributes = nil, &elements)
47
+ write('<style', '</style>', attributes, &elements)
48
+ end
49
+ end
50
+
51
+ module HTMLBodyElement
52
+ def body(attributes = nil, &elements)
53
+ write('<body', '</body>', attributes, &elements)
54
+ end
55
+ end
56
+
57
+ module HTMLElement
58
+ def article(attributes = nil, &elements)
59
+ write('<article', '</article>', attributes, &elements)
60
+ end
61
+
62
+ def section(attributes = nil, &elements)
63
+ write('<section', '</section>', attributes, &elements)
64
+ end
65
+
66
+ def nav(attributes = nil, &elements)
67
+ write('<nav', '</nav>', attributes, &elements)
68
+ end
69
+
70
+ def aside(attributes = nil, &elements)
71
+ write('<aside', '</aside>', attributes, &elements)
72
+ end
73
+
74
+ def hgroup(attributes = nil, &elements)
75
+ write('<hgroup', '</hgroup>', attributes, &elements)
76
+ end
77
+
78
+ def header(attributes = nil, &elements)
79
+ write('<header', '</header>', attributes, &elements)
80
+ end
81
+
82
+ def footer(attributes = nil, &elements)
83
+ write('<footer', '</footer>', attributes, &elements)
84
+ end
85
+
86
+ def address(attributes = nil, &elements)
87
+ write('<address', '</address>', attributes, &elements)
88
+ end
89
+
90
+ def dt(attributes = nil, &elements)
91
+ write('<dt', '</dt>', attributes, &elements)
92
+ end
93
+
94
+ def dd(attributes = nil, &elements)
95
+ write('<dd', '</dd>', attributes, &elements)
96
+ end
97
+
98
+ def figure(attributes = nil, &elements)
99
+ write('<figure', '</figure>', attributes, &elements)
100
+ end
101
+
102
+ def figcaption(attributes = nil, &elements)
103
+ write('<figcaption', '</figcaption>', attributes, &elements)
104
+ end
105
+
106
+ def main(attributes = nil, &elements)
107
+ write('<main', '</main>', attributes, &elements)
108
+ end
109
+
110
+ def search(attributes = nil, &elements)
111
+ write('<search', '</search>', attributes, &elements)
112
+ end
113
+
114
+ def em(attributes = nil, &elements)
115
+ write('<em', '</em>', attributes, &elements)
116
+ end
117
+
118
+ def strong(attributes = nil, &elements)
119
+ write('<strong', '</strong>', attributes, &elements)
120
+ end
121
+
122
+ def small(attributes = nil, &elements)
123
+ write('<small', '</small>', attributes, &elements)
124
+ end
125
+
126
+ def s(attributes = nil, &elements)
127
+ write('<s', '</s>', attributes, &elements)
128
+ end
129
+
130
+ def cite(attributes = nil, &elements)
131
+ write('<cite', '</cite>', attributes, &elements)
132
+ end
133
+
134
+ def dfn(attributes = nil, &elements)
135
+ write('<dfn', '</dfn>', attributes, &elements)
136
+ end
137
+
138
+ def abbr(attributes = nil, &elements)
139
+ write('<abbr', '</abbr>', attributes, &elements)
140
+ end
141
+
142
+ def ruby(attributes = nil, &elements)
143
+ write('<ruby', '</ruby>', attributes, &elements)
144
+ end
145
+
146
+ def rt(attributes = nil, &elements)
147
+ write('<rt', '</rt>', attributes, &elements)
148
+ end
149
+
150
+ def rp(attributes = nil, &elements)
151
+ write('<rp', '</rp>', attributes, &elements)
152
+ end
153
+
154
+ def code(attributes = nil, &elements)
155
+ write('<code', '</code>', attributes, &elements)
156
+ end
157
+
158
+ def var(attributes = nil, &elements)
159
+ write('<var', '</var>', attributes, &elements)
160
+ end
161
+
162
+ def samp(attributes = nil, &elements)
163
+ write('<samp', '</samp>', attributes, &elements)
164
+ end
165
+
166
+ def kbd(attributes = nil, &elements)
167
+ write('<kbd', '</kbd>', attributes, &elements)
168
+ end
169
+
170
+ def sub(attributes = nil, &elements)
171
+ write('<sub', '</sub>', attributes, &elements)
172
+ end
173
+
174
+ def sup(attributes = nil, &elements)
175
+ write('<sup', '</sup>', attributes, &elements)
176
+ end
177
+
178
+ def i(attributes = nil, &elements)
179
+ write('<i', '</i>', attributes, &elements)
180
+ end
181
+
182
+ def b(attributes = nil, &elements)
183
+ write('<b', '</b>', attributes, &elements)
184
+ end
185
+
186
+ def u(attributes = nil, &elements)
187
+ write('<u', '</u>', attributes, &elements)
188
+ end
189
+
190
+ def mark(attributes = nil, &elements)
191
+ write('<mark', '</mark>', attributes, &elements)
192
+ end
193
+
194
+ def bdi(attributes = nil, &elements)
195
+ write('<bdi', '</bdi>', attributes, &elements)
196
+ end
197
+
198
+ def bdo(attributes = nil, &elements)
199
+ write('<bdo', '</bdo>', attributes, &elements)
200
+ end
201
+
202
+ def wbr(attributes = nil)
203
+ # no child elements allowed and no closing tag
204
+ write('<wbr', '>', attributes)
205
+ end
206
+
207
+ def summary(attributes = nil, &elements)
208
+ write('<summary', '</summary>', attributes, &elements)
209
+ end
210
+
211
+ def noscript(attributes = nil, &elements)
212
+ write('<noscript', '</noscript>', attributes, &elements)
213
+ end
214
+
215
+ def acronym(attributes = nil, &elements)
216
+ write('<acronym', '</acronym>', attributes, &elements)
217
+ end
218
+
219
+ def noframes(attributes = nil, &elements)
220
+ write('<noframes', '</noframes>', attributes, &elements)
221
+ end
222
+
223
+ def menuitem(attributes = nil, &elements)
224
+ write('<menuitem', '</menuitem>', attributes, &elements)
225
+ end
226
+
227
+ def noembed(attributes = nil, &elements)
228
+ write('<noembed', '</noembed>', attributes, &elements)
229
+ end
230
+
231
+ def plaintext(attributes = nil, &elements)
232
+ write('<plaintext', '</plaintext>', attributes, &elements)
233
+ end
234
+
235
+ def rb(attributes = nil, &elements)
236
+ write('<rb', '</rb>', attributes, &elements)
237
+ end
238
+
239
+ def rtc(attributes = nil, &elements)
240
+ write('<rtc', '</rtc>', attributes, &elements)
241
+ end
242
+
243
+ def strike(attributes = nil, &elements)
244
+ write('<strike', '</strike>', attributes, &elements)
245
+ end
246
+
247
+ def basefont(attributes = nil, &elements)
248
+ write('<basefont', '</basefont>', attributes, &elements)
249
+ end
250
+
251
+ def big(attributes = nil, &elements)
252
+ write('<big', '</big>', attributes, &elements)
253
+ end
254
+
255
+ def center(attributes = nil, &elements)
256
+ write('<center', '</center>', attributes, &elements)
257
+ end
258
+
259
+ def nobr(attributes = nil, &elements)
260
+ write('<nobr', '</nobr>', attributes, &elements)
261
+ end
262
+
263
+ def tt(attributes = nil, &elements)
264
+ write('<tt', '</tt>', attributes, &elements)
265
+ end
266
+ end
267
+
268
+ module HTMLHeadingElement
269
+ def h1(attributes = nil, &elements)
270
+ write('<h1', '</h1>', attributes, &elements)
271
+ end
272
+
273
+ def h2(attributes = nil, &elements)
274
+ write('<h2', '</h2>', attributes, &elements)
275
+ end
276
+
277
+ def h3(attributes = nil, &elements)
278
+ write('<h3', '</h3>', attributes, &elements)
279
+ end
280
+
281
+ def h4(attributes = nil, &elements)
282
+ write('<h4', '</h4>', attributes, &elements)
283
+ end
284
+
285
+ def h5(attributes = nil, &elements)
286
+ write('<h5', '</h5>', attributes, &elements)
287
+ end
288
+
289
+ def h6(attributes = nil, &elements)
290
+ write('<h6', '</h6>', attributes, &elements)
291
+ end
292
+ end
293
+
294
+ module HTMLParagraphElement
295
+ def p(attributes = nil, &elements)
296
+ write('<p', '</p>', attributes, &elements)
297
+ end
298
+ end
299
+
300
+ module HTMLHRElement
301
+ def hr(attributes = nil)
302
+ # no child elements allowed and no closing tag
303
+ write('<hr', '>', attributes)
304
+ end
305
+ end
306
+
307
+ module HTMLPreElement
308
+ def pre(attributes = nil, &elements)
309
+ write('<pre', '</pre>', attributes, &elements)
310
+ end
311
+
312
+ def listing(attributes = nil, &elements)
313
+ write('<listing', '</listing>', attributes, &elements)
314
+ end
315
+
316
+ def xmp(attributes = nil, &elements)
317
+ write('<xmp', '</xmp>', attributes, &elements)
318
+ end
319
+ end
320
+
321
+ module HTMLQuoteElement
322
+ def blockquote(attributes = nil, &elements)
323
+ write('<blockquote', '</blockquote>', attributes, &elements)
324
+ end
325
+
326
+ def q(attributes = nil, &elements)
327
+ write('<q', '</q>', attributes, &elements)
328
+ end
329
+ end
330
+
331
+ module HTMLOListElement
332
+ def ol(attributes = nil, &elements)
333
+ write('<ol', '</ol>', attributes, &elements)
334
+ end
335
+ end
336
+
337
+ module HTMLUListElement
338
+ def ul(attributes = nil, &elements)
339
+ write('<ul', '</ul>', attributes, &elements)
340
+ end
341
+ end
342
+
343
+ module HTMLMenuElement
344
+ def menu(attributes = nil, &elements)
345
+ write('<menu', '</menu>', attributes, &elements)
346
+ end
347
+ end
348
+
349
+ module HTMLLIElement
350
+ def li(attributes = nil, &elements)
351
+ write('<li', '</li>', attributes, &elements)
352
+ end
353
+ end
354
+
355
+ module HTMLDListElement
356
+ def dl(attributes = nil, &elements)
357
+ write('<dl', '</dl>', attributes, &elements)
358
+ end
359
+ end
360
+
361
+ module HTMLDivElement
362
+ def div(attributes = nil, &elements)
363
+ write('<div', '</div>', attributes, &elements)
364
+ end
365
+ end
366
+
367
+ module HTMLAnchorElement
368
+ def a(attributes = nil, &elements)
369
+ write('<a', '</a>', attributes, &elements)
370
+ end
371
+ end
372
+
373
+ module HTMLDataElement
374
+ def data(attributes = nil, &elements)
375
+ write('<data', '</data>', attributes, &elements)
376
+ end
377
+ end
378
+
379
+ module HTMLTimeElement
380
+ def time(attributes = nil, &elements)
381
+ write('<time', '</time>', attributes, &elements)
382
+ end
383
+ end
384
+
385
+ module HTMLSpanElement
386
+ def span(attributes = nil, &elements)
387
+ write('<span', '</span>', attributes, &elements)
388
+ end
389
+ end
390
+
391
+ module HTMLBRElement
392
+ def br(attributes = nil)
393
+ # no child elements allowed and no closing tag
394
+ write('<br', '>', attributes)
395
+ end
396
+ end
397
+
398
+ module HTMLModElement
399
+ def ins(attributes = nil, &elements)
400
+ write('<ins', '</ins>', attributes, &elements)
401
+ end
402
+
403
+ def del(attributes = nil, &elements)
404
+ write('<del', '</del>', attributes, &elements)
405
+ end
406
+ end
407
+
408
+ module HTMLPictureElement
409
+ def picture(attributes = nil, &elements)
410
+ write('<picture', '</picture>', attributes, &elements)
411
+ end
412
+ end
413
+
414
+ module HTMLSourceElement
415
+ def source(attributes = nil)
416
+ # no child elements allowed and no closing tag
417
+ write('<source', '>', attributes)
418
+ end
419
+ end
420
+
421
+ module HTMLImageElement
422
+ def img(attributes = nil)
423
+ # no child elements allowed and no closing tag
424
+ write('<img', '>', attributes)
425
+ end
426
+ end
427
+
428
+ module HTMLIFrameElement
429
+ def iframe(attributes = nil, &elements)
430
+ write('<iframe', '</iframe>', attributes, &elements)
431
+ end
432
+ end
433
+
434
+ module HTMLEmbedElement
435
+ def embed(attributes = nil)
436
+ # no child elements allowed and no closing tag
437
+ write('<embed', '>', attributes)
438
+ end
439
+ end
440
+
441
+ module HTMLObjectElement
442
+ def object(attributes = nil, &elements)
443
+ write('<object', '</object>', attributes, &elements)
444
+ end
445
+ end
446
+
447
+ module HTMLVideoElement
448
+ def video(attributes = nil, &elements)
449
+ write('<video', '</video>', attributes, &elements)
450
+ end
451
+ end
452
+
453
+ module HTMLAudioElement
454
+ def audio(attributes = nil, &elements)
455
+ write('<audio', '</audio>', attributes, &elements)
456
+ end
457
+ end
458
+
459
+ module HTMLTrackElement
460
+ def track(attributes = nil)
461
+ # no child elements allowed and no closing tag
462
+ write('<track', '>', attributes)
463
+ end
464
+ end
465
+
466
+ module HTMLMapElement
467
+ def map(attributes = nil, &elements)
468
+ write('<map', '</map>', attributes, &elements)
469
+ end
470
+ end
471
+
472
+ module HTMLAreaElement
473
+ def area(attributes = nil)
474
+ # no child elements allowed and no closing tag
475
+ write('<area', '>', attributes)
476
+ end
477
+ end
478
+
479
+ module HTMLTableElement
480
+ def table(attributes = nil, &elements)
481
+ write('<table', '</table>', attributes, &elements)
482
+ end
483
+ end
484
+
485
+ module HTMLTableCaptionElement
486
+ def caption(attributes = nil, &elements)
487
+ write('<caption', '</caption>', attributes, &elements)
488
+ end
489
+ end
490
+
491
+ module HTMLTableColElement
492
+ def colgroup(attributes = nil, &elements)
493
+ write('<colgroup', '</colgroup>', attributes, &elements)
494
+ end
495
+
496
+ def col(attributes = nil)
497
+ # no child elements allowed and no closing tag
498
+ write('<col', '>', attributes)
499
+ end
500
+ end
501
+
502
+ module HTMLTableSectionElement
503
+ def tbody(attributes = nil, &elements)
504
+ write('<tbody', '</tbody>', attributes, &elements)
505
+ end
506
+
507
+ def thead(attributes = nil, &elements)
508
+ write('<thead', '</thead>', attributes, &elements)
509
+ end
510
+
511
+ def tfoot(attributes = nil, &elements)
512
+ write('<tfoot', '</tfoot>', attributes, &elements)
513
+ end
514
+ end
515
+
516
+ module HTMLTableRowElement
517
+ def tr(attributes = nil, &elements)
518
+ write('<tr', '</tr>', attributes, &elements)
519
+ end
520
+ end
521
+
522
+ module HTMLTableCellElement
523
+ def td(attributes = nil, &elements)
524
+ write('<td', '</td>', attributes, &elements)
525
+ end
526
+
527
+ def th(attributes = nil, &elements)
528
+ write('<th', '</th>', attributes, &elements)
529
+ end
530
+ end
531
+
532
+ module HTMLFormElement
533
+ def form(attributes = nil, &elements)
534
+ write('<form', '</form>', attributes, &elements)
535
+ end
536
+ end
537
+
538
+ module HTMLLabelElement
539
+ def label(attributes = nil, &elements)
540
+ write('<label', '</label>', attributes, &elements)
541
+ end
542
+ end
543
+
544
+ module HTMLInputElement
545
+ def input(attributes = nil)
546
+ # no child elements allowed and no closing tag
547
+ write('<input', '>', attributes)
548
+ end
549
+ end
550
+
551
+ module HTMLButtonElement
552
+ def button(attributes = nil, &elements)
553
+ write('<button', '</button>', attributes, &elements)
554
+ end
555
+ end
556
+
557
+ module HTMLSelectElement
558
+ def select(attributes = nil, &elements)
559
+ write('<select', '</select>', attributes, &elements)
560
+ end
561
+ end
562
+
563
+ module HTMLDataListElement
564
+ def datalist(attributes = nil, &elements)
565
+ write('<datalist', '</datalist>', attributes, &elements)
566
+ end
567
+ end
568
+
569
+ module HTMLOptGroupElement
570
+ def optgroup(attributes = nil, &elements)
571
+ write('<optgroup', '</optgroup>', attributes, &elements)
572
+ end
573
+ end
574
+
575
+ module HTMLOptionElement
576
+ def option(attributes = nil, &elements)
577
+ write('<option', '</option>', attributes, &elements)
578
+ end
579
+ end
580
+
581
+ module HTMLTextAreaElement
582
+ def textarea(attributes = nil, &elements)
583
+ write('<textarea', '</textarea>', attributes, &elements)
584
+ end
585
+ end
586
+
587
+ module HTMLOutputElement
588
+ def output(attributes = nil, &elements)
589
+ write('<output', '</output>', attributes, &elements)
590
+ end
591
+ end
592
+
593
+ module HTMLProgressElement
594
+ def progress(attributes = nil, &elements)
595
+ write('<progress', '</progress>', attributes, &elements)
596
+ end
597
+ end
598
+
599
+ module HTMLMeterElement
600
+ def meter(attributes = nil, &elements)
601
+ write('<meter', '</meter>', attributes, &elements)
602
+ end
603
+ end
604
+
605
+ module HTMLFieldSetElement
606
+ def fieldset(attributes = nil, &elements)
607
+ write('<fieldset', '</fieldset>', attributes, &elements)
608
+ end
609
+ end
610
+
611
+ module HTMLLegendElement
612
+ def legend(attributes = nil, &elements)
613
+ write('<legend', '</legend>', attributes, &elements)
614
+ end
615
+ end
616
+
617
+ module HTMLDetailsElement
618
+ def details(attributes = nil, &elements)
619
+ write('<details', '</details>', attributes, &elements)
620
+ end
621
+ end
622
+
623
+ module HTMLDialogElement
624
+ def dialog(attributes = nil, &elements)
625
+ write('<dialog', '</dialog>', attributes, &elements)
626
+ end
627
+ end
628
+
629
+ module HTMLScriptElement
630
+ def script(attributes = nil, &elements)
631
+ write('<script', '</script>', attributes, &elements)
632
+ end
633
+ end
634
+
635
+ module HTMLTemplateElement
636
+ def template(attributes = nil, &elements)
637
+ write('<template', '</template>', attributes, &elements)
638
+ end
639
+ end
640
+
641
+ module HTMLSlotElement
642
+ def slot(attributes = nil, &elements)
643
+ write('<slot', '</slot>', attributes, &elements)
644
+ end
645
+ end
646
+
647
+ module HTMLCanvasElement
648
+ def canvas(attributes = nil, &elements)
649
+ write('<canvas', '</canvas>', attributes, &elements)
650
+ end
651
+ end
652
+
653
+ module HTMLUnknownElement
654
+ def applet(attributes = nil, &elements)
655
+ write('<applet', '</applet>', attributes, &elements)
656
+ end
657
+
658
+ def bgsound(attributes = nil, &elements)
659
+ write('<bgsound', '</bgsound>', attributes, &elements)
660
+ end
661
+
662
+ def isindex(attributes = nil, &elements)
663
+ write('<isindex', '</isindex>', attributes, &elements)
664
+ end
665
+
666
+ def keygen(attributes = nil, &elements)
667
+ write('<keygen', '</keygen>', attributes, &elements)
668
+ end
669
+
670
+ def nextid(attributes = nil, &elements)
671
+ write('<nextid', '</nextid>', attributes, &elements)
672
+ end
673
+
674
+ def blink(attributes = nil, &elements)
675
+ write('<blink', '</blink>', attributes, &elements)
676
+ end
677
+
678
+ def multicol(attributes = nil, &elements)
679
+ write('<multicol', '</multicol>', attributes, &elements)
680
+ end
681
+
682
+ def spacer(attributes = nil, &elements)
683
+ write('<spacer', '</spacer>', attributes, &elements)
684
+ end
685
+ end
686
+
687
+ module HTMLDirectoryElement
688
+ def dir(attributes = nil, &elements)
689
+ write('<dir', '</dir>', attributes, &elements)
690
+ end
691
+ end
692
+
693
+ module HTMLFrameElement
694
+ def frame(attributes = nil, &elements)
695
+ write('<frame', '</frame>', attributes, &elements)
696
+ end
697
+ end
698
+
699
+ module HTMLFrameSetElement
700
+ def frameset(attributes = nil, &elements)
701
+ write('<frameset', '</frameset>', attributes, &elements)
702
+ end
703
+ end
704
+
705
+ module HTMLParamElement
706
+ def param(attributes = nil, &elements)
707
+ write('<param', '</param>', attributes, &elements)
708
+ end
709
+ end
710
+
711
+ module HTMLFontElement
712
+ def font(attributes = nil, &elements)
713
+ write('<font', '</font>', attributes, &elements)
714
+ end
715
+ end
716
+
717
+ module HTMLMarqueeElement
718
+ def marquee(attributes = nil, &elements)
719
+ write('<marquee', '</marquee>', attributes, &elements)
720
+ end
721
+ end
722
+
723
+ module HTMLAllElements
724
+ include HTMLHtmlElement
725
+ include HTMLHeadElement
726
+ include HTMLTitleElement
727
+ include HTMLBaseElement
728
+ include HTMLLinkElement
729
+ include HTMLMetaElement
730
+ include HTMLStyleElement
731
+ include HTMLBodyElement
732
+ include HTMLElement
733
+ include HTMLHeadingElement
734
+ include HTMLParagraphElement
735
+ include HTMLHRElement
736
+ include HTMLPreElement
737
+ include HTMLQuoteElement
738
+ include HTMLOListElement
739
+ include HTMLUListElement
740
+ include HTMLMenuElement
741
+ include HTMLLIElement
742
+ include HTMLDListElement
743
+ include HTMLDivElement
744
+ include HTMLAnchorElement
745
+ include HTMLDataElement
746
+ include HTMLTimeElement
747
+ include HTMLSpanElement
748
+ include HTMLBRElement
749
+ include HTMLModElement
750
+ include HTMLPictureElement
751
+ include HTMLSourceElement
752
+ include HTMLImageElement
753
+ include HTMLIFrameElement
754
+ include HTMLEmbedElement
755
+ include HTMLObjectElement
756
+ include HTMLVideoElement
757
+ include HTMLAudioElement
758
+ include HTMLTrackElement
759
+ include HTMLMapElement
760
+ include HTMLAreaElement
761
+ include HTMLTableElement
762
+ include HTMLTableCaptionElement
763
+ include HTMLTableColElement
764
+ include HTMLTableSectionElement
765
+ include HTMLTableRowElement
766
+ include HTMLTableCellElement
767
+ include HTMLFormElement
768
+ include HTMLLabelElement
769
+ include HTMLInputElement
770
+ include HTMLButtonElement
771
+ include HTMLSelectElement
772
+ include HTMLDataListElement
773
+ include HTMLOptGroupElement
774
+ include HTMLOptionElement
775
+ include HTMLTextAreaElement
776
+ include HTMLOutputElement
777
+ include HTMLProgressElement
778
+ include HTMLMeterElement
779
+ include HTMLFieldSetElement
780
+ include HTMLLegendElement
781
+ include HTMLDetailsElement
782
+ include HTMLDialogElement
783
+ include HTMLScriptElement
784
+ include HTMLTemplateElement
785
+ include HTMLSlotElement
786
+ include HTMLCanvasElement
787
+ include HTMLUnknownElement
788
+ include HTMLDirectoryElement
789
+ include HTMLFrameElement
790
+ include HTMLFrameSetElement
791
+ include HTMLParamElement
792
+ include HTMLFontElement
793
+ include HTMLMarqueeElement
794
+ end
795
+ end
796
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FunHtml
4
+ VERSION = "0.1.0"
5
+ end
data/lib/fun_html.rb ADDED
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'fun_html/node_definitions'
4
+ require_relative 'fun_html/attribute_definitions'
5
+ require_relative 'fun_html/version'
6
+ require 'erb/escape'
7
+
8
+ # nodoc
9
+ module FunHtml
10
+ # nodoc
11
+ module Writer
12
+ def include(func)
13
+ begin
14
+ @__buffer << func.render
15
+ # it is faster to error and try than to detect the type and branch
16
+ rescue StandardError
17
+ instance_exec(&func)
18
+ end
19
+ self
20
+ end
21
+
22
+ def text(value)
23
+ (@__buffer ||= +'') << ERB::Escape.html_escape(value)
24
+ self
25
+ end
26
+
27
+ def attr(&blk) # rubocop:disable Style/ArgumentsForwarding
28
+ Attribute.new(&blk) # rubocop:disable Style/ArgumentsForwarding
29
+ end
30
+
31
+ def comment(&elements)
32
+ write('<!--', '-->', nil, closing_char: '', closing_void_char: '-->', &elements)
33
+ end
34
+
35
+ def doctype
36
+ (@__buffer ||= +'') << '<!DOCTYPE html>'
37
+ end
38
+
39
+ def render
40
+ @__buffer
41
+ ensure
42
+ # empty the buffer to prevent double rendering
43
+ @__buffer = +''
44
+ end
45
+
46
+ private
47
+
48
+ CLOSE = '>'
49
+ CLOSE_VOID = '/>'
50
+
51
+ def write(open, close, attr = nil, closing_char: CLOSE, closing_void_char: CLOSE_VOID, &block)
52
+ (@__buffer ||= +'') << open << Attribute.to_html(attr)
53
+
54
+ if block
55
+ @__buffer << closing_char
56
+
57
+ begin
58
+ yield
59
+ # it is faster to error and try than to detect the type and branch
60
+ rescue StandardError
61
+ instance_eval(&block)
62
+ end
63
+ @__buffer << close
64
+ else
65
+ @__buffer << closing_void_char
66
+ end
67
+
68
+ self
69
+ end
70
+ end
71
+
72
+ # nodoc
73
+ class Template
74
+ include FunHtml::Writer
75
+ include FunHtml::NodeDefinitions::HTMLAllElements
76
+ end
77
+
78
+ # nodoc
79
+ class Attribute
80
+ include FunHtml::AttributeDefinitions
81
+
82
+ # only allow nil or objects that respond to `safe_attribute`
83
+ def self.to_html(attr)
84
+ attr&.safe_attribute.to_s
85
+ end
86
+
87
+ # create a new Attribute object to create reuseable attributes
88
+ def initialize(buffer = {}, &block)
89
+ @__buffer = buffer
90
+ instance_eval(&block) if block
91
+ end
92
+
93
+ # merge two attribute sets together
94
+ def merge(other)
95
+ self.class.new(@__buffer.merge(other.instance_variable_get(:@__buffer)))
96
+ end
97
+
98
+ def safe_attribute
99
+ @__buffer.values.join
100
+ end
101
+
102
+ private
103
+
104
+ def write(name, value)
105
+ @__buffer[name] = "#{name}#{ERB::Escape.html_escape(value)}\""
106
+ end
107
+
108
+ def write_empty(name, print)
109
+ @__buffer[name] = print ? name : ''
110
+ end
111
+ end
112
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fun_html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Weir
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: It probably is not much fun, despite the name.
14
+ email:
15
+ - john.weir@pharos-ei.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/fun_html.rb
21
+ - lib/fun_html/attribute_definitions.rb
22
+ - lib/fun_html/node_definitions.rb
23
+ - lib/fun_html/version.rb
24
+ homepage: https://github.com/jweir/fun_html
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://github.com/jweir/fun_html
29
+ source_code_uri: https://github.com/jweir/fun_html
30
+ changelog_uri: https://github.com/jweir/fun_html/CHANGES.md
31
+ rubygems_mfa_required: 'true'
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.4.1
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: HTML Generator via Ruby classes, not templates.
51
+ test_files: []