Skip to content

Commit

Permalink
Fixes #248: make sure to unlock the binding metadata before updatin…
Browse files Browse the repository at this point in the history
…g its value
  • Loading branch information
yihui committed Nov 2, 2015
1 parent e4660a3 commit 72bc5ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,13 @@ render <- function(input,
# knit environment (unless it is already defined there in which case
# we emit a warning)
env <- environment(render)
metadata_this <- env$metadata
do.call("unlockBinding", list("metadata", env))
on.exit({
env$metadata <- list()
if (bindingIsLocked("metadata", env)) {
do.call("unlockBinding", list("metadata", env))
}
env$metadata <- metadata_this
lockBinding("metadata", env)
}, add = TRUE)
env$metadata <- yaml_front_matter
Expand Down
3 changes: 3 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ rmarkdown 0.8.3 (unreleased)

* Always use the graphics package for PDF output

* Fix for the error "cannot change value of locked binding for 'metadata'" when
one call of rmarkdown::render() is nested in another one (#248)

rmarkdown 0.8.1
--------------------------------------------------------------------------------

Expand Down

1 comment on commit 72bc5ad

@mattsigal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Yihui!

Please sign in to comment.