Skip to content

Commit

Permalink
fix issue #58
Browse files Browse the repository at this point in the history
  • Loading branch information
hv10 authored and daavoo committed Jun 13, 2022
1 parent 66802e2 commit a1e5f7f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dvc_render/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ def embed(self) -> str:
self.PLOTS_PLACEHOLDER: "\n".join(self.elements),
self.REFRESH_PLACEHOLDER: self.refresh_tag,
}
return self.template.format(**kwargs)
for placeholder, value in kwargs.items():
self.template = self.template.replace(
"{" + placeholder + "}", value
)
return self.template


def render_html(
Expand Down
23 changes: 23 additions & 0 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
</body>
</html>"""

CSS_PAGE_HTML = """<!DOCTYPE html>
<html>
<head>
<title>TITLE</title>
<script type="text/javascript" src="vega"></script>
<script type="text/javascript" src="vega-lite"></script>
<script type="text/javascript" src="vega-embed"></script>
<style>
.test-malformed{
color: red;
}
</style>
</head>
<body>
{plot_divs}
</body>
</html>"""


@pytest.mark.parametrize(
"template,page_elements,expected_page",
Expand All @@ -32,6 +50,11 @@
["content"],
CUSTOM_PAGE_HTML.format(plot_divs="content"),
),
(
CSS_PAGE_HTML,
["content"],
CSS_PAGE_HTML.replace("{plot_divs}", "content"),
),
],
)
def test_html(template, page_elements, expected_page):
Expand Down

0 comments on commit a1e5f7f

Please sign in to comment.