#!/usr/bin/env python3 from pathlib import Path from jinja2 import Environment, FileSystemLoader # Test template rendering env = Environment(loader=FileSystemLoader(".")) template = env.get_template("templates/gallery.html") # Mock data test_items = [{ "name": "test_plot", "pdf_href": "test_plot.pdf", "png_href": "test_plot.png", "metadata": {"key1": "value1", "key2": "value2"} }] test_config = { "paths": {"work_dir": "/work/kschmidt/web"}, "ui": {"search_debounce_ms": 300, "max_recent_plots": 20} } rendered = template.render( title="Test Gallery", items=test_items, subdirs=["test_subdir"], relpath="test/path", paths=test_config["paths"], ui=test_config["ui"], stats={"file_count": 1, "folder_count": 1, "total_size": "100 KB", "total_size_bytes": 100000}, folder_metadata={}, assets_path="../assets" ) # Extract just the metadata button part lines = rendered.split('\n') for i, line in enumerate(lines): if 'metadata-btn' in line: print(f"Line {i}: {line.strip()}") if i > 0: print(f"Line {i-1}: {lines[i-1].strip()}") if i < len(lines)-1: print(f"Line {i+1}: {lines[i+1].strip()}") break print("\n--- Assets path in template ---") for i, line in enumerate(lines): if 'assets_path' in line: print(f"Line {i}: {line.strip()}")