std.html.VoidElement
type pub inline VoidElementAn element without an explicit closing tag, such as the <link> element.
Instance methods
attr
Show source codeHide source code
fn pub inline move attr(name: String, value: String) -> Self {
html.add(' ')
html.attr(name, value)
self
}fn pub inline move attr(name: String, value: String) -> SelfAdds an attribute to self.
Examples
import std.html (Html)
let doc = Html.empty
doc.p.attr('key', 'value').close
doc.to_string # => '<p key="value"></p>'
bool
Show source codeHide source code
fn pub inline move bool(name: String, value: Bool) -> Self {
if value { attr(name, '') } else { self }
}fn pub inline move bool(name: String, value: Bool) -> SelfAdds a boolean attribute to self.
If value is true then the attribute is added, otherwise it's ignored.
Examples
import std.html (Html)
let doc = Html.empty
doc.input.attr('type', 'checkbox').bool('checked', true).close
doc.to_string # => '<input type="checkbox" checked>'
class
Show source codeHide source code
fn pub inline move class(value: String) -> Self {
attr('class', value)
}fn pub inline move class(value: String) -> SelfAdds the class global attribute to self.
Examples
import std.html (Html)
let doc = Html.empty
doc.p.class('example').close
doc.to_string # => '<p class="example"></p>'
close
Show source codeHide source code
fn pub inline move close {
@open = false
@html.add('>')
}fn pub inline move closeAdds the closing tag for self and consumes it.
This method should be called when a RegularElement or VoidElement is
created and other moving methods such as RegularElement.text aren't used.
Examples
import std.html (Html)
let doc = Html.empty
doc.link.close
doc.to_string # => '<link>'
data
Show source codeHide source code
fn pub inline move data(name: String, value: String) -> Self {
html.add(' data-')
html.attr(name, value)
self
}fn pub inline move data(name: String, value: String) -> SelfAdds a data attribute to self.
Examples
import std.html (Html)
let doc = Html.empty
doc.p.data('key', 'value').close
doc.to_string # => '<p data-key="value"></p>'
id
Show source codeHide source code
fn pub inline move id(value: String) -> Self {
attr('id', value)
}fn pub inline move id(value: String) -> SelfAdds the id global attribute to self.
Examples
import std.html (Html)
let doc = Html.empty
doc.p.id('example').close
doc.to_string # => '<p id="example"></p>'
lang
Show source codeHide source code
fn pub inline move lang(value: String) -> Self {
attr('lang', value)
}fn pub inline move lang(value: String) -> SelfAdds the lang global attribute to self.
Examples
import std.html (Html)
let doc = Html.empty
doc.p.lang('example').close
doc.to_string # => '<p lang="example"></p>'
title
Show source codeHide source code
fn pub inline move title(value: String) -> Self {
attr('title', value)
}fn pub inline move title(value: String) -> SelfAdds the title global attribute to self.
Examples
import std.html (Html)
let doc = Html.empty
doc.p.title('example').close
doc.to_string # => '<p title="example"></p>'
Implemented traits
Drop
impl Drop for VoidElement