html_dsl/types/html
Types
Similar to a pair, but uniquely named
pub type Attribute {
Attribute(key: String, value: String)
}
Constructors
-
Attribute(key: String, value: String)
Exists to prevent strings from being passed to engines
Engines should require Html
or Component
pub opaque type Html
Functions
pub fn a(
id: Id,
class: Class,
href: String,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an anchor element
@param
id: The id of the element@param
class: The class of the element@param
href: The href of the anchor@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn article(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents an article element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn aside(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents an aside element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn attribute(key: String, value: String) -> Attribute
This function is used to create an Attribute
@param
key: The key of the attribute@param
value: The value of the attribute@returns
: An Attribute
pub fn body(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents the body of an HTML document
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn br() -> String
This creates a string that represents a break element
@returns
: A string that represents the HTML element
pub fn button(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents a button element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn charset(set: String) -> Head
This creates a string that represents a meta charset
@param
charset: the intended charset@return
: A Head
pub fn component(content: String) -> Html
This creates a string that represents a component
@param
content: The content of the component@returns
: A Component
pub fn div(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents a div element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn footer(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents a footer element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn form(
id: Id,
class: Class,
attributes: List(Attribute),
children: List(Input),
) -> String
This creates a string that represents a form element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn h1(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an h1 element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn h2(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an h2 element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn h3(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an h3 element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn h4(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an h4 element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn h5(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an h5 element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn h6(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents an h6 element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn head(children: List(Head)) -> String
This creates a string that represents the head of an HTML document
@param
children: A list of Head elements@returns
: A string that represents the HTML element
pub fn header(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents a header element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn hr() -> String
This creates a string that represents a horizontal rule element
@returns
: A string that represents the HTML element
pub fn html(lang: String, children: String) -> Html
This creates a string that represents an HTML document
@param
lang: The language of the document@param
children: The children of the document@returns
: A string that represents the HTML element
pub fn img(
id: Id,
class: Class,
src: String,
alt: String,
attributes: List(Attribute),
) -> String
This creates a string that represents an image element
@param
id: The id of the element@param
class: The class of the element@param
src: The source of the image@param
alt: The alt text of the image@param
attributes: The attributes of the element@returns
: A string that represents the HTML element
pub fn input(
id: Id,
class: Class,
attributes: List(Attribute),
input_type: InputType,
placeholder: String,
) -> Input
This creates a string that represents an input element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
input_type: The type of the input@param
placeholder: The placeholder of the input@returns
: An Input
pub fn is_html(html: Html) -> Bool
Check Html enum
@param
html: The Html enum@returns
: True if the Html enum is Html, False if it is Component
pub fn label(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> Input
This creates a string that represents a label element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: An Input
pub fn li(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> ListItem
This creates a string that represents a list item element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A ListItem
pub fn link(
rel: String,
href: String,
attributes: List(Attribute),
) -> Head
This creates a string that represents a link element
@param
rel: The relationship of the link@param
href: The href of the link@param
attributes: The attributes of the link@returns
: A Head
pub fn main(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents a main element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn meta(name: String, content: String) -> Head
This creates a string that represents a meta element
@param
name: The name of the meta@param
content: The content of the meta@returns
: A Head
pub fn nav(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents a nav element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn new_element(content: String) -> Input
Element is part of an opaque type, so it can’t be accessed directly
This function is used to create an Element
@param
content: The content of the element@returns
: An Element
pub fn ol(
id: Id,
class: Class,
attributes: List(Attribute),
children: List(ListItem),
) -> String
This creates a string that represents an ordered list element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: a list of ListItems@returns
: A string that represents the HTML element
pub fn option(value: String, children: String) -> Option
This creates a string that represents an option element
@param
value: The value of the option@param
children: The children of the option@returns
: An Option
pub fn p(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents a paragraph element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn render_attribute(attribute: Attribute) -> String
This function is used to create a ListItem
@param
content: The content of the list item@returns
: A ListItem
pub fn script(src: String) -> Head
This creates a string that represents a script element
@param
src: The source of the script@returns
: A Head
pub fn section(
id: Id,
class: Class,
attributes: List(Attribute),
children: String,
) -> String
This creates a string that represents a section element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: The children of the element@returns
: A string that represents the HTML element
pub fn select(
id: Id,
class: Class,
attributes: List(Attribute),
options: List(Option),
) -> String
This creates a string that represents a select element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
options: The options of the select@returns
: A string that represents the HTML element
pub fn span(
id: Id,
class: Class,
attributes: List(Attribute),
child: String,
) -> String
This creates a string that represents a span element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
child: The child of the element@returns
: A string that represents the HTML element
pub fn style(src: String) -> Head
This creates a string that represents a special link element for stylesheets
@param
src: The source of the stylesheet@returns
: A Head
pub fn title(content: String) -> Head
This creates a string that represents a title element
@param
content: The content of the title@returns
: A Head
pub fn ul(
id: Id,
class: Class,
attributes: List(Attribute),
children: List(ListItem),
) -> String
This creates a string that represents an unordered list element
@param
id: The id of the element@param
class: The class of the element@param
attributes: The attributes of the element@param
children: a list of ListItems@returns
: A string that represents the HTML element