Skip to content

Commit

Permalink
Merge pull request #66 from devOpifex/engine
Browse files Browse the repository at this point in the history
Engine
  • Loading branch information
JohnCoene authored Apr 7, 2024
2 parents 42055ea + b1ca584 commit 0590c02
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion R/response.R
Original file line number Diff line number Diff line change
Expand Up @@ -817,4 +817,4 @@ deprecated_status <- function(status = NULL) {
package = "ambiorix",
msg = "Deprecated. Pass status to the `status` binding, e.g.: `res$status <- 404L`."
)
}
}
13 changes: 13 additions & 0 deletions R/routing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
}
Expand Down
1 change: 1 addition & 0 deletions man/Ambiorix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/Router.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/Routing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0590c02

Please sign in to comment.