tag_f: Make Functions That Wrap Text in HTML Tags

Description Usage Arguments Details Value Note Examples

View source: R/html.R

Description

Helper functions to generate functions to use as slots for the StyleHtml@funs classes. These are functions that return functions.

Usage

1
2
3
4
5
6
7
tag_f(tag, class = character(), style = character())

div_f(class = character(), style = character())

span_f(class = character(), style = character())

cont_f(class = character())

Arguments

tag

character(1L) a name of an HTML tag

class

character the CSS class(es)

style

named character inline styles, where the name is the CSS property and the value the value.

Details

tag_f and related functions (div_f, span_f) produce functions that are vectorized and will apply opening and closing tags to each element of a character vector. container_f on the other hand produces a function will collapse a character vector into length 1, and only then applies the tags. Additionally, container_f already comes with the “diffobj-container” class specified.

Value

a function that accepts a character parameter. If applied, each element in the character vector will be wrapped in the div tags

Note

inputs are assumed to be valid class names or CSS styles.

Examples

1
2
3
4
5
6
7
## Assuming class 'ex1' has CSS styles defined elsewhere
tag_f("div", "ex1")(LETTERS[1:5])
## Use convenience function, and add some inline styles
div_f("ex2", c(color="green", `font-family`="arial"))(LETTERS[1:5])
## Notice how this is a div with pre-specifed class,
## and only one div is created around the entire data
cont_f()(LETTERS[1:5])

diffobj documentation built on Oct. 5, 2021, 9:07 a.m.