# Path: silhouette/loaders.py
# class DefaultLoader(object):
#     def get_substitutes(self, obj, path, theme):
#     def get_template(self, obj, template_type, path=None, theme=None, patterns=None):
#     def __call__(self, *args, **kwargs):
# 
# Path: silhouette/utils.py
# def normalize(name):
#     return re.sub('(((?<=[a-z])[A-Z1-9])|([A-Z1-9](?![A-Z1-9]|$)))', '_\\1', name).strip('_').lower()


import re
from django.template import Library
from django.template.loader import get_template
from django.utils import six
from django.utils.encoding import force_text
    from django.template.base import TemplateDoesNotExist
    from django.template.exceptions import TemplateDoesNotExist
from ..loaders import get_silhouette
from ..utils import normalize
    """
    Base class for Silhouette Renderers

    """
    PATH_CONTEXT_KEY = 'silhouette_path'
    THEME_CONTEXT_KEY = 'silhouette_theme'

    def __init__(self, context, obj, template=None, theme=None, path=None, **kwargs):
        self.context = context
        self.obj = obj
        self.path_override = path or context.get(self.PATH_CONTEXT_KEY, None)
        self.theme_override = theme or context.get(self.THEME_CONTEXT_KEY, None)
        self.template_override = template
        self.kwargs = kwargs

    def __enter__(self):
        scope = {self.PATH_CONTEXT_KEY: self.path_override, self.THEME_CONTEXT_KEY: self.theme_override}
        scope.update(self.get_extra_context())
        self.context.update(scope)
        return self.context

    def __exit__(self, *args, **kwargs):
        self.context.pop()

    @property
    def template_type(self):
        """
        Template type to use when loading the tag template. It corresponds to a key in silhouette.settings.PATTERNS.

        """

# Path: silhouette/loaders.py
# class DefaultLoader(object):
#     def get_substitutes(self, obj, path, theme):
#     def get_template(self, obj, template_type, path=None, theme=None, patterns=None):
#     def __call__(self, *args, **kwargs):
# 
# Path: silhouette/utils.py
# def normalize(name):
#     return re.sub('(((?<=[a-z])[A-Z1-9])|([A-Z1-9](?![A-Z1-9]|$)))', '_\\1', name).strip('_').lower()


# Path: silhouette/templatetags/silhouette_tags.py
import re
from django.template import Library
from django.template.loader import get_template
from django.utils import six
from django.utils.encoding import force_text
    from django.template.base import TemplateDoesNotExist
    from django.template.exceptions import TemplateDoesNotExist
from ..loaders import get_silhouette
from ..utils import normalize

    """
    Base class for Silhouette Renderers

    """
    PATH_CONTEXT_KEY = 'silhouette_path'
    THEME_CONTEXT_KEY = 'silhouette_theme'

    def __init__(self, context, obj, template=None, theme=None, path=None, **kwargs):
        self.context = context
        self.obj = obj
        self.path_override = path or context.get(self.PATH_CONTEXT_KEY, None)
        self.theme_override = theme or context.get(self.THEME_CONTEXT_KEY, None)
        self.template_override = template
        self.kwargs = kwargs

    def __enter__(self):
        scope = {self.PATH_CONTEXT_KEY: self.path_override, self.THEME_CONTEXT_KEY: self.theme_override}
        scope.update(self.get_extra_context())
        self.context.update(scope)
        return self.context

    def __exit__(self, *args, **kwargs):
        self.context.pop()

    @property
    def template_type(self):
        """
        Template type to use when loading the tag template. It corresponds to a key in silhouette.settings.PATTERNS.

        """

        return normalize(type(self).__name__)