diff --git a/NEWS.md b/NEWS.md index 0e068e5..c90ec2c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ in memory. - Added `use_html_template` to use `htmltools::htmlTemplate` as rendering. - Custom renderers (`as_renderer`) are now more robust. +- Fix issue with setting custom websocket handler [#62](https://github.com/devOpifex/ambiorix/issues/62). +- Add `engine` method on router to set custom renderers (`use` deprecated for custom renderers). # ambiorix 2.1.0 diff --git a/R/response.R b/R/response.R index 3a0b57e..5d602ea 100644 --- a/R/response.R +++ b/R/response.R @@ -817,4 +817,4 @@ deprecated_status <- function(status = NULL) { package = "ambiorix", msg = "Deprecated. Pass status to the `status` binding, e.g.: `res$status <- 404L`." ) -} \ No newline at end of file +} diff --git a/R/routing.R b/R/routing.R index c7fded2..33c7fca 100644 --- a/R/routing.R +++ b/R/routing.R @@ -227,6 +227,14 @@ Routing <- R6::R6Class( cli::cli_rule("Ambiorix", right = "web server") cli::cli_li("routes: {.val {private$n_routes()}}") }, + #' @details Engine to use for rendering templates. + engine = function(engine){ + if(!is_renderer_obj(engine)) + engine <- as_renderer(engine) + + self$use(engine) + invisible(self) + }, #' @details Use a router or middleware #' @param use Either a router as returned by [Router], a function to use as middleware, #' or a `list` of functions. @@ -259,6 +267,11 @@ Routing <- R6::R6Class( } if(is_renderer_obj(use)) { + .Deprecated( + "engine", + package = "ambiorix", + msg = "Use `engine` instead of `use` for custom renderers." + ) .globals$renderer <- use return(invisible(self)) } diff --git a/man/Ambiorix.Rd b/man/Ambiorix.Rd index 24c9486..fbf1ae7 100644 --- a/man/Ambiorix.Rd +++ b/man/Ambiorix.Rd @@ -165,6 +165,7 @@ if(interactive())