Skip to contents

Writes an HTML widget's main container <div> and data <script> tags to file.

Usage

write_widget(x, path)

Arguments

x

HTML widget object.

path

File path to write the HTML widget's core tags to.

Value

The content written to path as a character scalar, invisibly.

Details

Other than htmlwidgets::saveWidget(), this function does not write a complete HTML document but only the widget's core tags. Hence it is intended to create files which are in turn included in another HTML file, e.g. via a static site generator. The HTML widget's dependencies must be handled separately, e.g. using write_widget_deps().

To directly get the HTML widget's core tags as a character scalar, use as.character(htmltools::tagList(x)).

See also

Other HTML widget functions: write_widget_deps()