Functions
register
Register data manipulation functions with Jinja2 environment.
register
def register(env: Environment, site: Site) -> None
Register data manipulation functions with Jinja2 environment.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
env |
Environment |
— | |
site |
Site |
— |
get_data
Load data from JSON or YAML file.
Uses bengal.utils.file_io.load_data_file internally for robust f…
get_data
def get_data(path: str, root_path: Any) -> Any
Load data from JSON or YAML file.
Uses bengal.utils.file_io.load_data_file internally for robust file loading with error handling and logging.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
path |
str |
— | Relative path to data file |
root_path |
Any |
— | Site root path |
Returns
Parsed data (dict, list, or primitive)Any
—
jsonify
Convert data to JSON string.
jsonify
def jsonify(data: Any, indent: int | None = None) -> str
Convert data to JSON string.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
data |
Any |
— | Data to convert (dict, list, etc.) |
indent |
int | None |
None |
Indentation level (default: None for compact) |
Returns
JSON stringstr
—
merge
Merge two dictionaries.
Delegates to bengal.config.merge.deep_merge for consistent behavior
across…
merge
def merge(dict1: dict[str, Any], dict2: dict[str, Any], deep: bool = True) -> dict[str, Any]
Merge two dictionaries.
Delegates to bengal.config.merge.deep_merge for consistent behavior across the codebase.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
dict1 |
dict[str, Any] |
— | First dictionary |
dict2 |
dict[str, Any] |
— | Second dictionary (takes precedence) |
deep |
bool |
True |
Perform deep merge (default: True) |
Returns
Merged dictionarydict[str, Any]
—
has_key
Check if dictionary has a key.
has_key
def has_key(data: dict[str, Any], key: str) -> bool
Check if dictionary has a key.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
data |
dict[str, Any] |
— | Dictionary to check |
key |
str |
— | Key to look for |
Returns
True if key existsbool
—
get_nested
Access nested data using dot notation.
get_nested
def get_nested(data: dict[str, Any], path: str, default: Any = None) -> Any
Access nested data using dot notation.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
data |
dict[str, Any] |
— | Dictionary with nested data |
path |
str |
— | Dot-separated path (e.g., "user.profile.name") |
default |
Any |
None |
Default value if path not found |
Returns
Value at path or defaultAny
—
keys_filter
Get dictionary keys as list.
keys_filter
def keys_filter(data: dict[str, Any]) -> list[str]
Get dictionary keys as list.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
data |
dict[str, Any] |
— | Dictionary or DotDict |
Returns
List of keyslist[str]
—
values_filter
Get dictionary values as list.
values_filter
def values_filter(data: dict[str, Any]) -> list[Any]
Get dictionary values as list.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
data |
dict[str, Any] |
— | Dictionary or DotDict |
Returns
List of valueslist[Any]
—
items_filter
Get dictionary items as list of (key, value) tuples.
items_filter
def items_filter(data: dict[str, Any]) -> list[tuple[str, Any]]
Get dictionary items as list of (key, value) tuples.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
data |
dict[str, Any] |
— | Dictionary or DotDict |
Returns
List of (key, value) tupleslist[tuple[str, Any]]
—