Skip to content

Commit

Permalink
Release v0.2.1
Browse files Browse the repository at this point in the history
Merge pull request #10 from riccardoporreca/hotfix/handle-missing-type_field
* Fix handling of missing `type_field`
  • Loading branch information
riccardoporreca authored Mar 29, 2020
2 parents eff7a65 + 2606fb1 commit cae177f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rmdgallery
Title: R Markdown Website Gallery Generator
Version: 0.2.0
Version: 0.2.1
Authors@R:
person(given = "Riccardo",
family = "Porreca",
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# rmdgallery 0.2.1

## Patch release

- Fix handling of missing `type_field` in the `gallery` site configuration (#10).

# rmdgallery 0.2.0

## New features
Expand Down
5 changes: 3 additions & 2 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ gallery_site_config <- function(input = ".") {
config
}

with_type_template <- function(meta, gallery_config)(
with_type_template <- function(meta, gallery_config) {
if (!is.null(gallery_config$type_field)) {
meta <- assign_type_template(
meta,
gallery_config$type_field,
gallery_config$type_template
)
}
)
meta
}

assign_type_template <- function(meta, type_field, type_templates) {
template <- get_meta_field(meta, "template")
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ test_that("Setting templates by type errors if templates are missing for certain
)
})

test_that("Setting templates by type handles no type_field", {
expect_identical(
with_type_template(meta, list()),
meta
)
})

test_that("Setting defaults works", {
defaults <- list(
template = "def_tpl", # partly-specified field
Expand Down

0 comments on commit cae177f

Please sign in to comment.