Shortcodes
This module contains implementations for the shortcodes content filters
- integreat_cms.cms.utils.shortcodes.expand_shortcodes(content: str, context: dict[str, Any] | None = None) str[source]
Contact
- integreat_cms.cms.utils.shortcodes.contact.contact(pargs: list[str], kwargs: dict[str, str], context: dict[str, Any] | None, content: str = '') str[source]
Shortcode to insert a contact card with details from a
Contact.Positional arguments:
contact_id– The id of theContactwhose details should be displayed
The remaining positional arguments might be of the following:
address(optional) – Whether the address should be shown and other, not explicitly wanted details should be hiddenemail(optional) – Whether the email address should be shown and other, not explicitly wanted details should be hiddenphone_number(optional) – Whether the phone number should be shown and other, not explicitly wanted details should be hiddenmobile_phone_number(optional) – Whether the mobile phone number should be shown and other, not explicitly wanted details should be hiddenwebsite(optional) – Whether the website should be shown and other, not explicitly wanted details should be hidden
Page
- integreat_cms.cms.utils.shortcodes.page.page(pargs: list[str], kwargs: dict[str, str], context: dict[str, Any] | None, content: str = '') str[source]
Shortcode to insert an internal link to a
Page.Positional arguments:
page_id– The id of thePageto which should be linkedlink_text(optional) – If not given, the title of the publicPageTranslationis used
If the target page has an icon set and the shortcode has no
link_text, the icon will be included as an<ìmg>before the page title.Examples [page 1]<a href="/augsburg/de/willkommen/">Willkommen</a>[page 1 "this page"]<a href="/augsburg/de/willkommen/">this page</a>[page 999999]<i>[MISSING LINK]</i>
Utils
- integreat_cms.cms.utils.shortcodes.utils.shortcode(tag: Callable[[P], R] | str | None, endtag: str | None = None) Callable[[Callable[[P], R]], Callable[[P], R]] | Callable[[P], R][source]
Decorator to register a function as a shortcode
For example, this would declare a shortcode
cat(taken from the function name), where the first parameter can be0or1to select between two ASCII cats to insert:@shortcode def cat(pargs, kwargs, context, content=""): cats = ''' (=^・ω・^=) ฅ/ᐠ- ˕ -マ '''.split() return cats[pargs[0]]
If the shortcode should use a different keyword than just the name of the function, it can be provided as an argument to the decorator:
@shortcode("ASCII_cat") def cat(pargs, kwargs, context, content=""): […]When
endtagis given, the shortcode will not be atomic but can enclose content between its opening tag and end tag:@shortcode("cat", "tac") def cat(pargs, kwargs, context, content=""): return f"⚞({content})⚟"
This can then be used as
[cat]some <b>feline content</b>[tac].