Write a minimal HTML file with widget views embedded.

    Parameters
    ----------
    fp: filename or file-like object
        The file to write the HTML output to.
    {views_attribute}
    title: title of the html page.
    template: Template in which to embed the widget state.
        This should be a Python string with placeholders
        `{{title}}` and `{{snippet}}`. The `{{snippet}}` placeholder
        will be replaced by all the widgets.
    {embed_kwargs}

def embed_minimal_html(fp, views, title=u'IPyWidget export', template=None, **kwargs):
    """Write a minimal HTML file with widget views embedded.

    Parameters
    ----------
    fp: filename or file-like object
        The file to write the HTML output to.
    {views_attribute}
    title: title of the html page.
    template: Template in which to embed the widget state.
        This should be a Python string with placeholders
        `{{title}}` and `{{snippet}}`. The `{{snippet}}` placeholder
        will be replaced by all the widgets.
    {embed_kwargs}
    """
    snippet = embed_snippet(views, **kwargs)

    values = {
        'title': title,
        'snippet': snippet,
    }
    if template is None:
        template = html_template

    html_code = template.format(**values)

    # Check if fp is writable:
    if hasattr(fp, 'write'):
        fp.write(html_code)
    else:
        # Assume fp is a filename:
        with open(fp, "w") as f:
            f.write(html_code)