Configuration¶
PyJinHx provides several configuration options for customizing template discovery and rendering behavior.
Default Environment¶
The default Jinja environment controls where templates are loaded from.
Auto-Detection¶
By default, PyJinHx walks upward from the current directory to find your project root:
Project root is detected by looking for common markers:
pyproject.tomlmain.pyREADME.md.git.gitignorepackage.jsonuv.lock.venv
Setting a Custom Path¶
from pyjinhx import Renderer
# Set explicit template path
Renderer.set_default_environment("./components")
# Now all components look for templates under ./components
Using a Jinja Environment¶
For full control, pass a Jinja Environment:
from jinja2 import Environment, FileSystemLoader
from pyjinhx import Renderer
env = Environment(
loader=FileSystemLoader("./templates"),
autoescape=True,
trim_blocks=True,
lstrip_blocks=True,
)
Renderer.set_default_environment(env)
Clearing the Default¶
Logging¶
PyJinHx uses Python's standard logging:
Logged events include:
- Component class registration warnings (duplicates)
- Component instance registration warnings (ID conflicts)