Skip to content

html helper function bug #126

Closed
Closed

Description

@olegursu

html helper function recycles input value

tab_1 <-
  exibble %>%
  dplyr::select(currency, char) %>%
  dplyr::rename(term = char) %>%
  gt() %>%
  fmt(columns = vars(term),
                 fns = function(x) {
                   html(
                      sprintf("<a href=\"https://www.google.com/search?q=%s\">%s</a>", x, x)
                     )
                 })

tab_1

Activity

  1. rich-iannone commented on Jan 9, 2019

    @rich-iannone
    Member

    @olegursu What you have is pretty close but you actually need the text_transform() function. Any text you create with that will be accepted as HTML:

    tab_1 <-
      exibble %>%
      dplyr::select(currency, char) %>%
      dplyr::rename(term = char) %>%
      gt() %>%
      text_transform(
        locations = cells_data(columns = vars(term)),
        fn = function(x) {
          sprintf("<a href=\"https://www.google.com/search?q=%s\">%s</a>", x, x)
        })
    
    tab_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions