Extending

Extend Kida with custom filters, tests, globals, and loaders

1 min read 146 words

Extend Kida with custom functionality.

Quick Reference

from kida import Environment

env = Environment()

# Custom filter
@env.filter()
def double(value):
    return value * 2

# Custom test
@env.test()
def is_even(value):
    return value % 2 == 0

# Custom global
env.add_global("site_name", "My Site")

# Use in templates
# {{ count | double }}
# {% if count is even %}
# {{ site_name }}