tests/testthat/test-tmpl-glue.R

web <- setup({
  app <- new_app()
  app$engine("html", tmpl_glue())
  app$set_config("views", test_path("fixtures", "views"))
  app$get("/hello/:user", function(req, res) {
    locals <- c(as.list(req$params), greeting = "hello")
    html <- res$render("test-view", locals = locals)
    res$
      set_type("text/html")$
      send(html)
  })
  new_app_process(app)
})

teardown(web$stop())

test_that("glue templating", {
  url <- web$url("/hello/gabor")
  resp <- curl::curl_fetch_memory(url)
  expect_match(rawToChar(resp$content), "hello gabor")
})

Try the presser package in your browser

Any scripts or data that you put into this service are public.

presser documentation built on July 1, 2020, 5:49 p.m.