renderobject <- function(object, Routput, fnargs, cache=TRUE){
#block 'save' for GET
if(Routput == "save"){
stop("Output type /save cannot be used with method GET.")
}
#we evaluate the meta parameters.
if(length(fnargs) > 0){
#check for illegal code injection
if(any(substr(names(fnargs),1,1) == "#")){
stop("arguments are not allowed to start with a #");
}
#parse HTTP arguments and evaluate
fnargs <- lapply(fnargs, tryParse, disable.eval=TRUE);
#check for a seed
if(!is.null(fnargs[["!seed"]])){
set.seed(fnargs[["!seed"]]);
fnargs[["!seed"]] <- NULL;
}
}
#add the function as an argument
fnargs[["#dofn"]] <- "identity";
#load the object from the store
fnargs[["x"]] <- object;
#perform the actual request
returndata <- callfunction(fnargs, Routput);
#add default cache value
if(isTRUE(cache)){
returndata$cache <- config("cache.store");
} else {
returndata$cache <- FALSE
}
#return the list with content and type and status
return(returndata);
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.