I need to pass a variable via URL hash argument to a Shiny app that uses htmlTemplate() defined output. But ui = htmlTemplate(... line below fails with Error in eval(parse(text = piece), env) : object 'response' not found. Is it possible to pass an output from server to htmlTemplate()?
require(shiny)
page_template = '<style> h2 { color: red; } </style> <h2>{{response}}</h2>'
server = shinyServer(function(input, output, session) {
observe({
output$response = renderText({
session$clientData$url_hash
})
})
})
ui = htmlTemplate(text_ = page_template)
shinyApp(ui, server)
I've also tried
page_template = '<style> h2 { color: red; } </style> <h2>{{renderText("response")}}</h2>'
.. which does not error the app, but output in browser does not render:
<h2><div id="outa160c30ab8f687db" class="shiny-text-output"></div></h2>