Skip to contents

epoxy_style_html() provides a pug- like syntax for expressions in HTML that are wrapped in HTML elements.


You can specify the HTML element and its id and class into which the text of the expression will be placed. The template is to specify the element using the syntax below, followed by the R expression, separated by a space:

{{ [<element>][#<id> | .<class>...] expr }}

For example, to place the expression in a <li> element with id = "food" and class = "fruit", you could write

{{ li#food.fruit fruit_name }}

Each item in the HTML template is optional:

  1. If a specific HTML element is desired, the element name must be first. If no element is specified, the default as set by the element argument of epoxy_style_html() will be used.

  2. IDs are specified using #<id> and only one ID may be present

  3. Classes are written using .<class> and as many classes as desired are allowed.

If the expression is a vector, the same element container will be used for each item in the vector.


  class = NULL,
  element = "span",
  transformer = glue::identity_transformer



Additional classes to be added to the inline HTML element.


The default HTML element tag name to be used when an element isn't specified in the expression.


The transformer to apply to the replacement string. This argument is used for chaining the transformer functions. By providing a function to this argument you can apply an additional transformation after the current transformation. In nearly all cases, you can let epoxy_style() handle this for you. The chain ends when glue::identity_transformer() is used as the transformer.


A function of text and envir suitable for the .transformer argument of glue::glue().

See also

Used by default in epoxy_html()

Other epoxy-style glue transformers: epoxy_style_inline(), epoxy_style()


epoxy_html("<ul>{{ li letters[1:3] }}</ul>")
#> <ul><li>a</li></ul><ul><li>b</li></ul><ul><li>c</li></ul>
epoxy_html("<ul>{{ li.alpha letters[1:3] }}</ul>")
#> <ul><li class="alpha">a</li></ul><ul><li class="alpha">b</li></ul><ul><li class="alpha">c</li></ul>
epoxy_html("<ul>{{ li#my-letter letters[7] }}</ul>")
#> <ul><li id="my-letter">g</li></ul>

# The default element is used if no element is directly requested
epoxy_html("My name starts with {{ .name-letter letters[7] }}")
#> My name starts with <span class="name-letter">g</span>

  "{{ h3#title title }}",
  title = "Epoxy Style for HTML"
#> <h3 id="title">Epoxy Style for HTML</h3>