Search results

There are no results.

std.html.VoidElement

type pub inline VoidElement

An element without an explicit closing tag, such as the <link> element.

Instance methods

attr

Show source code
Hide 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) -> Self

Adds 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 code
Hide 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) -> Self

Adds 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 code
Hide source code
fn pub inline move class(value: String) -> Self {
  attr('class', value)
}
fn pub inline move class(value: String) -> Self

Adds 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 code
Hide source code
fn pub inline move close {
  @open = false
  @html.add('>')
}
fn pub inline move close

Adds 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 code
Hide 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) -> Self

Adds 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 code
Hide source code
fn pub inline move id(value: String) -> Self {
  attr('id', value)
}
fn pub inline move id(value: String) -> Self

Adds 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 code
Hide source code
fn pub inline move lang(value: String) -> Self {
  attr('lang', value)
}
fn pub inline move lang(value: String) -> Self

Adds 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 code
Hide source code
fn pub inline move title(value: String) -> Self {
  attr('title', value)
}
fn pub inline move title(value: String) -> Self

Adds 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

std.drop.

Drop

impl Drop for VoidElement