Description Usage Arguments Value Examples
Render arguments to a string of markup (HTML but also generic XML)
1 2 3 |
tag |
character The name of the html/xml tag to be used |
... |
the content of the tag. Eventually coerced into character vector. Can be list or function |
opts |
list of key=values for tag attributes |
specials |
list of shortcuts for setting ID and class attributes. Should be familiar to css users. Potentially extendable to to other attributes... |
escape.html.p |
logical predicate. Should all html be escaped? calls escape.html() on the final character output if TRUE |
singleton |
logical predicate. If TRUE the tag is of form <tag body> |
a character vector of length 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | {
m("p")
m("div")
# Any strings after that become the content of the tag
m("p", "This is a paragraph")
# Tags can be nested inside of tags and everything ends up concatenated
m("p", "Goodbye", m("strong", "cruel"), "world")
# You can specify attributes by supplying a list after the content
m("span", "bar", opts = list(class = "foo"))
#' There are CSS-style shortcuts for setting ID and class
m("p#my-p", m("span.pretty", "hey"))
m("span", opts = list(id = "foo", class = "bar"), "baz")
# You can escape a string using the (escape-html) function
m("p", m("script", "Do something evil", escape.html.p = TRUE))
# Also caters for singleton tags:
m("meta", opts = list(charset = "utf-8"), singleton = TRUE)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.