Skip to content
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
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ng2web ChangeLog

## Unreleased

**Released: WiP**

- Don't print template locations when using custom templates, when quiet
mode is requested. ([#53](https://github.com/davep/ng2web/pull/53))

## v1.5.1

**Released: 2025-12-08**
Expand Down
12 changes: 8 additions & 4 deletions src/ng2web/ng2web.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,24 +385,27 @@ def page_title(guide: NortonGuide, entry: Entry | None = None) -> str:


##############################################################################
def make_loader(templates: Path | None) -> ChoiceLoader:
def make_loader(templates: Path | None, quietly: bool) -> ChoiceLoader:
"""Make the template loader.

Args:
templates: Optional directory for template overrides.
quietly: Make without logging?

Returns:
Returns the template loader object.
"""
loaders: list[FileSystemLoader] = []
if templates is not None:
if (templates := templates.expanduser().resolve()).is_dir():
log(f"Adding {templates} to the template path")
if not quietly:
log(f"Adding {templates} to the template path")
loaders.append(FileSystemLoader(str(templates), followlinks=True))
else:
log(f"Ignoring {templates} as a template location as it does not exist")
if (local_templates := Path("templates").resolve()).is_dir():
log(f"Adding {local_templates} to the template path")
if not quietly:
log(f"Adding {local_templates} to the template path")
loaders.append(FileSystemLoader(str(local_templates), followlinks=True))
return ChoiceLoader(loaders + [PackageLoader(Path(__file__).stem)])

Expand Down Expand Up @@ -444,7 +447,8 @@ def to_html(args: argparse.Namespace) -> None:

# Bootstrap the template stuff.
env = Environment(
loader=make_loader(args.templates), autoescape=select_autoescape()
loader=make_loader(args.templates, args.quiet),
autoescape=select_autoescape(),
)

# Set up the global variables for template expansion.
Expand Down