Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues with inline resources on save #2794

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion panel/io/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def save(panel, filename, title=None, resources=None, template=None,
resources = Resources.from_bokeh(resources)

# Set resource mode
with set_resource_mode(mode):
with set_resource_mode(resources):
html = file_html(doc, resources, title, **kwargs)
if hasattr(filename, 'write'):
if isinstance(filename, io.BytesIO):
Expand Down
24 changes: 23 additions & 1 deletion panel/tests/io/test_save.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re

from io import StringIO

from panel.pane import Vega
from panel.pane import Alert, Vega
from panel.models.vega import VegaPlot


Expand Down Expand Up @@ -30,3 +32,23 @@ def test_save_external():
html = sio.read()
for js in VegaPlot.__javascript_raw__:
assert js in html


def test_save_inline_resources():
alert = Alert('# Save test')

sio = StringIO()
alert.save(sio, resources='inline')
sio.seek(0)
html = sio.read()
assert '.bk.alert-primary' in html


def test_save_cdn_resources():
alert = Alert('# Save test')

sio = StringIO()
alert.save(sio, resources='cdn')
sio.seek(0)
html = sio.read()
assert re.findall('https://unpkg.com/@holoviz/panel@(.*)/dist/css/alerts.css', html)