4

I built a DT table with a custom container, similar to the one here (point 2.6 - 2.6 Custom Table Container). I'm packaging the shiny app that uses this table and I want to find out what package th(), tr() and thead() functions, that are used to defined the sketch object, belong to..?

??theadetc. points me to various DT functions but ?DT::thead() returns no documentation. Thanks for any pointers!

Kasia Kulma
  • 1,683
  • 1
  • 14
  • 39
  • 1
    These are some fields of `tags` in the package `htmltools`: `tags$thead`, `tags$th`. You can access to these tags by doing `withTags(......)`, as in the link your provide. – Stéphane Laurent May 15 '19 at 13:27

1 Answers1

3

You should notice that in the definition of sketch they call htmltools::withTags which is fairly simple

function (code) 
{
    eval(substitute(code), envir = as.list(tags), enclos = parent.frame())
}
<bytecode: 0x000001c832d09200>
<environment: namespace:htmltools>

The thing to note is that it's going to use substitute and envir = as.list(tags). If we take a look at tags it's a list with the following named objects/functions:

> names(tags)
  [1] "a"           "abbr"        "address"     "area"        "article"     "aside"       "audio"      
  [8] "b"           "base"        "bdi"         "bdo"         "blockquote"  "body"        "br"         
 [15] "button"      "canvas"      "caption"     "cite"        "code"        "col"         "colgroup"   
 [22] "command"     "data"        "datalist"    "dd"          "del"         "details"     "dfn"        
 [29] "div"         "dl"          "dt"          "em"          "embed"       "eventsource" "fieldset"   
 [36] "figcaption"  "figure"      "footer"      "form"        "h1"          "h2"          "h3"         
 [43] "h4"          "h5"          "h6"          "head"        "header"      "hgroup"      "hr"         
 [50] "html"        "i"           "iframe"      "img"         "input"       "ins"         "kbd"        
 [57] "keygen"      "label"       "legend"      "li"          "link"        "mark"        "map"        
 [64] "menu"        "meta"        "meter"       "nav"         "noscript"    "object"      "ol"         
 [71] "optgroup"    "option"      "output"      "p"           "param"       "pre"         "progress"   
 [78] "q"           "ruby"        "rp"          "rt"          "s"           "samp"        "script"     
 [85] "section"     "select"      "small"       "source"      "span"        "strong"      "style"      
 [92] "sub"         "summary"     "sup"         "table"       "tbody"       "td"          "textarea"   
 [99] "tfoot"       "th"          "thead"       "time"        "title"       "tr"          "track"      
[106] "u"           "ul"          "var"         "video"       "wbr"   

Every one of those has essentially the same form:

> tags$thead
function (...) 
tag("thead", list(...))
<bytecode: 0x000001c82c4a2678>
<environment: namespace:htmltools>

So it's basically just a convenient way to call the tag function with the specified tag. An example of calling it directly:

> tag("thead", "This is my thead")
<thead>This is my thead</thead>
Dason
  • 60,663
  • 9
  • 131
  • 148