我正在尝试显示来自server.R代码的代码,以便我可以根据UI中的用户选择来驱动亚马逊广告。使用indluceHTML在ui.R中显示HTML很好,但是当我移动html代码时不执行server.R
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
titlePanel("Uploading Files"),
mainPanel(
htmlOutput("inc") # this code here does NOT produce the HTML output
),
includeHTML("include.html") # this code produces the HTML output
)
# Define server logic required to draw a histogram
server <- function(input, output) {
getPage<-function() {
return(includeHTML("include.html"))
}
output$inc<-renderUI({getPage()})
}
# Run the application
shinyApp(ui = ui, server = server)
这是我需要呈现的html - 某些字段xxx已经编辑了值。 include.html中的代码来自亚马逊,以便我可以连接到他们的添加页面。最终,我需要根据用户输入动态更改default_search_phrase。
include.html
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_search_bar = "true";
amzn_assoc_tracking_id = "xxxxxxxxxx";
amzn_assoc_search_bar_position = "bottom";
amzn_assoc_ad_mode = "search";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_title = "...on Amazon";
amzn_assoc_default_search_phrase = "Star Wars Black Series 6 Inch";
amzn_assoc_default_category = "All";
amzn_assoc_linkid = "xxxxxxxxxx";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
如果我在include.html文件中添加了一些简单的东西,两种方法都可以工作:
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>