tests/testthat/test-tmpl-glue.R

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)
})
web <- local_app_process(app)

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

Try the webfakes package in your browser

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

webfakes documentation built on May 29, 2024, 2:24 a.m.