Functions
register
Register file system functions with Jinja2 environment.
register
def register(env: Environment, site: Site) -> None
Register file system functions with Jinja2 environment.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
env |
Environment |
— | |
site |
Site |
— |
read_file
Read file contents.
Uses bengal.utils.file_io.read_text_file internally for robust file reading
wi…
read_file
def read_file(path: str, root_path: Path) -> str
Read file contents.
Uses bengal.utils.file_io.read_text_file internally for robust file reading with UTF-8/latin-1 encoding fallback and comprehensive error handling.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Relative path to file |
root_path |
Path |
— | Site root path |
Returns
File contents as stringstr
—
file_exists
Check if file exists.
file_exists
def file_exists(path: str, root_path: Path) -> bool
Check if file exists.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Relative path to file |
root_path |
Path |
— | Site root path |
Returns
True if file existsbool
—
file_size
Get human-readable file size.
file_size
def file_size(path: str, root_path: Path) -> str
Get human-readable file size.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Relative path to file |
root_path |
Path |
— | Site root path |
Returns
File size as human-readable string (e.g., "1.5 MB")str
—