How to use the turbokid.kidsupport.KidSupport.assume_encoding function in TurboKid

To help you get started, we’ve selected a few TurboKid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freeipa / freeipa / ipa-server / ipa-gui / ipagui / helpers / ipahelper.py View on Github external
def load_template(classname, encoding=None):
    """
    Loads the given template. This only handles .kid files.
    Returns a tuple (compiled_tmpl, None) to emulate
    turbogears.meta.load_kid_template() which ends up not properly handling
    encoding.
    """
    if not encoding:
        encoding = turbogears.config.get('kid.encoding', kidsupport.KidSupport.assume_encoding)
    divider = classname.rfind(".")
    package, basename = classname[:divider], classname[divider+1:]
    file_path = resource_filename(package, basename + ".kid")

    tclass = kid.load_template(
        file_path,
        name = classname,
        ).Template
    tclass.serializer = kid.HTMLSerializer(encoding=encoding)
    tclass.assume_encoding=encoding

    return (tclass, None)

TurboKid

Python template plugin that supports Kid templates

MIT
Latest version published 15 years ago

Package Health Score

42 / 100
Full package analysis

Similar packages