misc (14)
add¶
add(text: str | None, prefix: str = '', suffix: str = '') -> str
Add a pre- or suffix to a value if the value is true-ish.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The text to check |
required |
prefix
|
str
|
Prefix to add if text is true-ish |
''
|
suffix
|
str
|
Suffix to add if text is true-ish |
''
|
Source code in src/jinjarope/envglobals.py
attr¶
attr(environment: 'Environment', obj: Any, name: str) -> Union[jinja2.runtime.Undefined, Any]
Get an attribute of an object. foo|attr("bar") works like
Example
Jinja call:
Result:<built-in method removesuffix of str object at 0x7507417be070>
Example
Jinja call:
Result:[<built-in method upper of str object at 0x75075d12ccc0>, <built-in method upper of str object at 0x75075cd16280>]
DocStrings
Source code in jinja2/filters.py
check_output¶
check_output(call: 'str | Sequence[str]', cwd: 'str | os.PathLike[str] | None' = None, use_cache: 'bool' = False) -> 'str | None'
Execute a system call and return its output as a string.
Example
Jinja call:
Result:AGENTS.md README.md duties.py overrides src uv.lock
LICENSE docs mkdocs.yml pyproject.toml tests
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
call
|
str | Sequence[str]
|
The system call to make |
required |
cwd
|
str | PathLike[str] | None
|
The working directory for the call |
None
|
use_cache
|
bool
|
Whether to cache the output of calls |
False
|
Source code in src/jinjarope/envglobals.py
default¶
default(value: ~V, default_value: ~V = '', boolean: bool = False) -> ~V
If the value is undefined it will return the passed default value,
Aliases: d
DocStrings
Source code in jinja2/filters.py
get_hash¶
get_hash(obj: Any, hash_length: int | None = 7) -> str
Get a Md5 hash for given object.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to get a hash for () |
required |
hash_length
|
int | None
|
Optional cut-off value to limit length |
7
|
Source code in src/jinjarope/utils.py
getenv¶
getenv(key, default=None)
Get an environment variable, return None if it doesn't exist.
DocStrings
hasattr¶
hasattr(obj, name, /)
Return whether the object has an attribute with the given name.
DocStrings
import_module¶
import_module(name, package=None)
Import a module.
Example
Jinja call:
Result:<module 'jinja2' from '/home/runner/work/jinjarope/jinjarope/.venv/lib/python3.13/site-packages/jinja2/__init__.py'>
DocStrings
Source code in importlib/__init__.py
load_file¶
load_file(path: 'AnyPath') -> 'str'
Return the text-content of file at given path.
Example
Jinja call:
Result: `## Emoji extension indexMkNodes provides a custom emoji index for the pymdownx.emoji extension in order to provide access to all > 180.000 icons provided by the Iconify framework.
Example: becomes::mdi-file:
Info
For compatibility, icons can also be accessed from the same name as the Material-MkDocs icon index, making
the MkNodes index a superset of the MkDocs-Material index.
Icon node¶
MkNodes also includes a node for Pyconify-Icons named [MkIcon][mknodes.MkIcon]. It can be used to include icons with custom color, rotation and size. `
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
AnyPath
|
The path to get str content from |
required |
Source code in src/jinjarope/envglobals.py
map¶
map(context: 'Context', value: Iterable[Any], *args: Any, **kwargs: Any) -> Iterable[Any]
Applies a filter on a sequence of objects or looks up an attribute.
Example
Jinja call:
Result:<async_generator object do_map at 0x7507402b4340>
DocStrings
Source code in jinja2/filters.py
match¶
match(obj: Any, mapping: dict[str | type, str] | None = None, **kwargs: Any) -> str
A filter trying to imitate a python match-case statement.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
match object |
required |
mapping
|
dict[str | type, str] | None
|
a mapping for the different cases. If key is type, an isinstance will be performed. If key is a str, check for equality. |
None
|
kwargs
|
Any
|
Same functionality as mapping, but provided as keyword arguments for convenience. |
{}
|
Examples:
Source code in src/jinjarope/envglobals.py
partial¶
partial(fn: collections.abc.Callable[..., T], *args: Any, **kwargs: Any) -> collections.abc.Callable[..., T]
Create new function with partial application of given arguments / keywords.
Example
Jinja call:
Result:functools.partial(<function join at 0x75075d1836a0>, 'abc')
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., T]
|
The function to generate a partial from |
required |
args
|
Any
|
patially applied arguments |
()
|
kwargs
|
Any
|
partially applied keywords |
{}
|
Source code in src/jinjarope/utils.py
random¶
random(context: 'Context', seq: 't.Sequence[V]') -> 't.Union[V, Undefined]'
Return a random item from the sequence.
DocStrings
Source code in jinja2/filters.py
ternary¶
ternary(value: Any, true_val: TTrue, false_val: TFalse, none_val: Optional[TNone] = None) -> Union[bool, TTrue, TFalse, TNone]
Value ? true_val : false_val.
DocStrings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to check. |
required |
true_val
|
TTrue
|
The value to return if given value is true-ish |
required |
false_val
|
TFalse
|
The value to return if given value is false-ish |
required |
none_val
|
TNone | None
|
Optional value to return if given value is None |
None
|