diff --git a/htmltools/_core.py b/htmltools/_core.py
index ed4adbc..f8f794d 100644
--- a/htmltools/_core.py
+++ b/htmltools/_core.py
@@ -39,6 +39,8 @@
_html_escape, # type: ignore
_flatten, # type: ignore
hash_deterministic,
+ MISSING,
+ MISSING_TYPE,
)
__all__ = (
@@ -187,7 +189,11 @@ def tagify(self) -> "TagList":
return cp
def save_html(
- self, file: str, *, libdir: Optional[str] = "lib", include_version: bool = True
+ self,
+ file: str,
+ *,
+ libdir: Union[str, MISSING_TYPE] = MISSING,
+ include_version: bool = True,
) -> str:
"""
Save to a HTML file.
@@ -576,7 +582,11 @@ def render(self) -> RenderedHTML:
return {"dependencies": deps, "html": cp.get_html_string()}
def save_html(
- self, file: str, *, libdir: Optional[str] = "lib", include_version: bool = True
+ self,
+ file: str,
+ *,
+ libdir: Union[str, MISSING_TYPE] = MISSING,
+ include_version: bool = True,
) -> str:
"""
Save to a HTML file.
@@ -700,7 +710,10 @@ def append(self, *args: TagChildArg) -> None:
self._content.append(*args)
def render(
- self, *, lib_prefix: Optional[str] = "lib", include_version: bool = True
+ self,
+ *,
+ lib_prefix: Union[str, MISSING_TYPE] = MISSING,
+ include_version: bool = True,
) -> RenderedHTML:
"""
Render the document.
@@ -719,7 +732,10 @@ def render(
return rendered
def save_html(
- self, file: str, libdir: Optional[str] = "lib", include_version: bool = True
+ self,
+ file: str,
+ libdir: Union[str, MISSING_TYPE] = MISSING,
+ include_version: bool = True,
) -> str:
"""
Save the document to a HTML file.
@@ -736,9 +752,10 @@ def save_html(
# Directory where dependencies are copied to.
destdir = str(Path(file).resolve().parent)
- if libdir:
- destdir = os.path.join(destdir, libdir)
+ libdir = resolve_missing_lib_path(libdir)
+ destdir = os.path.join(destdir, libdir)
+ # TODO: fix all libdir occurrences
rendered = self.render(lib_prefix=libdir, include_version=include_version)
for dep in rendered["dependencies"]:
dep.copy_to(destdir, include_version=include_version)
@@ -753,12 +770,14 @@ def save_html(
# - lib_prefix: A directoy prefix to add to