## web.html -- generation of HTML5 web pages This module provides DSL-like interface to generate web pages, assuming the role commonly carried out by template engines. It encompasses HTML5 syntax, allowing to produce HTML documents and fragments of documents without writing actual HTML code, while benefiting from static checks provided by the language. ### Index namespace [html](#html) [Attribute types](#attrs) [Tag functions](#tags) Other functions: - [document](#document)(...: tuple<enum<manifest,xml_lang>, string> | GlobalAttr)[] => string - [fragment](#fragment)()[] => string - [text](#text)(text: string) - [comment](#comment)(text: string) ###Attribute types ```ruby type GlobalAttr = tuple, string> | tuple, enum|string> | tuple, tuple> | tuple, enum> | enum | tuple, bool> | tuple, int> | tuple, enum> | tuple, string> type Step = tuple, float|enum> type Target = tuple, enum|string> type FormTarget = tuple, enum|string> ``` These types represent corresponding HTML attributes and are provided to avoid unnecessary repetition of parameter types in function prototypes. ###Tag functions ```ruby anchor(...: tuple, string> | Target | tuple, enum> | GlobalAttr)[ => string|none ] abbrev(...: GlobalAttr)[ => string|none ] address(...: GlobalAttr)[ => string|none ] area(...: tuple, string> | Target | tuple, enum> | tuple, tuple<...: int>> | tuple, enum> | GlobalAttr) article(...: GlobalAttr)[ => string|none ] aside(...: GlobalAttr)[ => string|none ] audio(...: enum | tuple, enum> | tuple, string> | GlobalAttr)[ => string|none ] base(...: tuple, string> | Target | GlobalAttr) bdi(...: GlobalAttr)[ => string|none ] bdo(...: GlobalAttr)[ => string|none ] blockquote(...: tuple, string> | GlobalAttr)[ => string|none ] body(...: tuple, string> | GlobalAttr)[ => string|none ] bold(...: GlobalAttr)[ => string|none ] br(...: GlobalAttr) button(kind: enum, ...: tuple, string> | FormTarget | enum | tuple, enum> | GlobalAttr) [ => string|none ] button(kind: enum, ...: tuple, string> | enum | GlobalAttr)[ => string|none ] canvas(...: tuple, int> | GlobalAttr)[ => string|none ] caption(...: GlobalAttr)[ => string|none ] cite(...: GlobalAttr)[ => string|none ] code(...: GlobalAttr)[ => string|none ] col(...: tuple, int> | GlobalAttr) colgroup(...: tuple, int> | GlobalAttr)[ => string|none ] command(kind: enum, ...: tuple, string> | enum | GlobalAttr) command(kind: enum, ...: tuple, string> | enum | GlobalAttr) command(kind: enum, ...: tuple, string> | enum | GlobalAttr) datalist(...: GlobalAttr)[ => string|none ] dd(...: GlobalAttr)[ => string|none ] del(...: tuple, string> | GlobalAttr)[ => string|none ] details(...: enum | GlobalAttr)[ => string|none ] dfn(...: GlobalAttr)[ => string|none ] div(...: GlobalAttr)[ => string|none ] dl(...: GlobalAttr)[ => string|none ] dt(...: GlobalAttr)[ => string|none ] em(...: GlobalAttr)[ => string|none ] embed(...: tuple, string> | tuple, int> | GlobalAttr) fieldset(...: tuple, string> | enum | GlobalAttr)[ => string|none ] figcaption(...: GlobalAttr)[ => string|none ] figure(...: GlobalAttr)[ => string|none ] footer(...: GlobalAttr)[ => string|none ] form(...: tuple, string> | Target | enum | tuple, enum> | tuple, enum> | GlobalAttr) [ => string|none ] h1(...: GlobalAttr)[ => string|none ] h2(...: GlobalAttr)[ => string|none ] h3(...: GlobalAttr)[ => string|none ] h4(...: GlobalAttr)[ => string|none ] h5(...: GlobalAttr)[ => string|none ] h6(...: GlobalAttr)[ => string|none ] head(...: GlobalAttr)[ => string|none ] header(...: GlobalAttr)[ => string|none ] hgroup(...: GlobalAttr)[ => string|none ] hr(...: GlobalAttr) iframe(...: tuple, string> | tuple, int> | tuple, enum> | enum | GlobalAttr)[ => string|none ] img(...: tuple, string> | tuple, int> | enum | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, int> | enum | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, int> | enum | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | tuple, string> | enum | FormTarget | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | tuple, string> | enum | FormTarget | tuple, enum> | tuple, int> | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | tuple, enum> | Step | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, float> | Step | enum | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, float> | enum | tuple, enum> | Step | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, int> | enum | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, int> | enum | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | tuple, int> | enum | tuple, enum> | GlobalAttr) input(kind: enum, ...: tuple, string> | enum | tuple, enum> | GlobalAttr) ins(...: tuple, string> | GlobalAttr)[ => string|none ] italic(...: GlobalAttr)[ => string|none ] kbd(...: GlobalAttr)[ => string|none ] keygen(...: tuple, string> | tuple, enum> | enum | GlobalAttr)[ => string|none ] label(...: tuple, string> | GlobalAttr)[ => string|none ] legend(...: tuple, int> | GlobalAttr)[ => string|none ] li(...: tuple, int> | GlobalAttr)[ => string|none ] link(...: tuple, string> | tuple, enum> | GlobalAttr) map(...: tuple, string> | GlobalAttr)[ => string|none ] mark(...: GlobalAttr)[ => string|none ] menu(kind: enum, ...: tuple, string> | GlobalAttr)[ => string|none ] meta(...: tuple, string> | GlobalAttr) meta(...: tuple, enum> | tuple, string> | GlobalAttr) meta(...: tuple, string> | GlobalAttr) meter(...: tuple, float> | GlobalAttr)[ => string|none ] nav(...: GlobalAttr)[ => string|none ] noscript(...: GlobalAttr)[ => string|none ] object(...: tuple, string> | tuple, int> | GlobalAttr)[ => string|none ] ol(...: tuple, string> | tuple, int> | enum | GlobalAttr) [ => string|none ] optgroup(...: tuple, string> | enum | GlobalAttr)[ => string|none ] option(...: tuple, string> | enum | GlobalAttr)[ => string|none ] output(...: tuple, string> | GlobalAttr)[ => string|none ] paragraph(...: GlobalAttr)[ => string|none ] param(...: tuple, string> | GlobalAttr) pre(...: GlobalAttr)[ => string|none ] progress(...: tuple, float> | GlobalAttr)[ => string|none ] quoted(...: tuple, string> | GlobalAttr)[ => string|none ] rp(...: GlobalAttr)[ => string|none ] ruby(...: GlobalAttr)[ => string|none ] struck(...: GlobalAttr)[ => string|none ] samp(...: GlobalAttr)[ => string|none ] script(...: tuple, string> | enum | GlobalAttr)[ => string|none ] section(...: GlobalAttr)[ => string|none ] select(...: tuple, string> | tuple, int> | enum | GlobalAttr)[ => string|none ] small(...: GlobalAttr)[ => string|none ] source(...: tuple, string> | GlobalAttr) span(...: GlobalAttr)[ => string|none ] strong(...: GlobalAttr)[ => string|none ] style(...: tuple, string> | enum | GlobalAttr)[ => string|none ] sub(...: GlobalAttr)[ => string|none ] summary(...: GlobalAttr)[ => string|none ] sup(...: GlobalAttr)[ => string|none ] table(...: tuple, string> | GlobalAttr)[ => string|none ] tbody(...: GlobalAttr)[ => string|none ] td(...: tuple, int> | tuple, invar>> | GlobalAttr) [ => string|none ] textarea(...: tuple, string> | enum | tuple, int> | tuple, enum> | GlobalAttr)[ => string|none ] tfoot(...: GlobalAttr)[ => string|none ] th(...: tuple, enum> | tuple, int> | tuple, invar>> | GlobalAttr)[ => string|none ] thead(...: GlobalAttr)[ => string|none ] time(...: tuple, string> | GlobalAttr)[ => string|none ] title(...: GlobalAttr)[ => string|none ] tr(...: GlobalAttr)[ => string|none ] track(...: tuple, enum> | tuple, string> | enum | GlobalAttr) underlined(...: GlobalAttr)[ => string|none ] ul(...: GlobalAttr)[ => string|none ] variable(...: GlobalAttr)[ => string|none ] video(...: tuple, enum> | enum | tuple, string> | tuple, int> | GlobalAttr) [ => string|none ] wbr(...: GlobalAttr) ``` Each tag routine corresponds to individual HTML element. Code section routine indicates element which may have content, i.e. nested tags, text or comments. Tag routines, [text()](#text) and [comment()](#comment) called within such code sections are automatically nested inside the corresponding parent tag in the resulting HTML code. To avoid unnecessary text() calls, all code sections support `string` as returned value to be used for elements whose content can be specified as a single `string` value. __Note:__ For elements which wrap short text fragments ('em', 'q', 'span', etc.) it is often better to directly use HTML markup within strings -- it may appear more concise and clear in certain cases. Strings which are code section results and [text()](#text) arguments may include arbitrary HTML code. Element attributes may be specified via variadic parameters, each of which is either a named value (attribute with a value) or `enum` (void attribute). All tag routines support parameters of type `GlobalAttr`, which covers all global HTML attributes. Routine names mostly match those of HTML tags; however, there are few exceptions made to avoid naming conflicts: - 'a' -> 'anchor'; - 'b' -> 'bold'; - 'i' -> 'italic'; - 'p' -> 'paragraph'; - 'q' -> 'qouted'; - 's' -> 'struck'; - 'u' -> 'underlined'; - 'var' -> 'variable'. That is, all single-letter tags (plus 'var') are replaced with the corresponding full words. Attribute names also mostly match HTML specification; the exceptions are: - 'type', 'class' and 'for' start with '_' as they are Dao keywords; - the names originally containing '-' and ':' ('xml:lang') use '_' instead; - 'data-*' attributes are provided via `data_` parameter accepting name-value tuple. __Note:__ For `data_` parameter, any '_' in its name suffix is replaced with '-'. Additionally, `button()`, `command()` and `input()` do not accept 'type' attribute as named value, instead expecting single `enum` value as the first, non-variadic routine argument. This allows to provide overloaded version of these routines with different parameter sets similar to HTML specification for these tags. **Errors:** `HTML` when used ouside of [document{}](#document) or [fragment{}](#fragment), or within a different task ###Other functions ```ruby document(...: tuple, string> | GlobalAttr)[] => string ``` Returns HTML 5 document composed from content specified in the code section. Includes '' and 'html' tag with the specified attributes **Errors:** `HTML` in case of nested contexts ```ruby fragment()[] => string ``` Returns HTML 5 code fragment composed from content specified in the code section **Errors:** `HTML` in case of nested contexts ```ruby text(text: string) ``` Specifies plain *text*, but may as well contain arbitrary HTML markup (*text* is included 'as-is' into the resulting HTML code) **Errors:** `HTML` when used ouside of [document{}](#document) or [fragment{}](#fragment), or within a different task ```ruby comment(text: string) ``` Specifies comment with the given *text* **Errors:** `HTML` when used ouside of [document{}](#document) or [fragment{}](#fragment), or within a different task