Skip to content

ambiorix-web/pugger

Repository files navigation

pugger

Use the pug templating engine with ambiorix.

Installation

# install.packages("remotes")
remotes::install_github("devOpifex/pugger")

Use

Set the custom template with app$engine() ⚠️ on older versions of ambiorix one had to use the use method.

Example

Render the following test.pug file.

doctype html
html(lang="en")
  head
    title= pageTitle
    script(type='text/javascript').
      if (foo) bar(1 + 5);
  body
    h1 Pug - node template engine
    #container.col
      if iUsePugger
        p You are amazing
      else
        p Get on it!
      p.
        Pug is a terse and simple templating language with a
        strong focus on performance and powerful features.

With the following app.

library(ambiorix)

app <- Ambiorix$new()

# on older versions of ambiorix
# app$use(pugger::pugger())
app$use(pugger::pugger())

app$get("/", \(req, res) {
  res$render(
    "test.pug",
    list(
      iUsePugger = TRUE
    )
  )
})

app$start()

Outside of Ambiorix

Just use renderer.

pugger::renderer(
  "test.pug",
  list(
    iUsePugger = TRUE
  )
)