Skip to contents

[Stable] Puts named templates on the page, so a tag can use one with tip_on(tag, template = "name"). Put the result in the page's UI, once. Names are page-wide. A name is lower-case letters, digits and _, starting with a letter; inside a Shiny module, prefix it with ns() (for example tip_define(!!ns("row") := tip_template(...))) so two copies of the module keep their own templates without overwriting each other. Defining the same name again replaces the earlier template under it, with a warning when the blocks differ.

Usage

tip_define(...)

Arguments

...

Templates, each with a name: tip_define(diff = tip_template(...)), or in a Shiny module tip_define(!!ns("diff") := tip_template(...)). A template may also be a list of blocks. Supports dynamic dots (rlang::list2()).

Value

Tags to put in the page's UI.

Details

The templates are also kept in R, so that tip_on() can check a record against them. Defined in a Shiny session (in renderUI() or a module's server), they belong to that session: two sessions of one app may define one name with different fields and each is checked against its own. Defined where the UI is built, they belong to the process and every session is checked against them; a session may define the name again for itself, without a warning. A renderUI() that is cached with bindCache() does not run again for the next session, so a template it defines is known in R only to the session that ran it: define a template that sessions share where the UI is built.

Examples

tip_define(
  diff = tip_template(
    tip_title("{{ label }}"),
    tip_text("{{ differences | number:0 }} differences")
  )
)
#> <script type="application/json" data-hovercraft-ops="">[{"op":"define","name":"diff","blocks":[{"type":"title","text":"{{ label }}"},{"type":"text","text":"{{ differences | number:0 }} differences"}]}]</script>