# Path: contentious/api.py
# class ContentiousInterface(object):
#     def in_edit_mode(self, template_context):
#     def get_content_data(self, key, template_context):
#     def save_content_data(self, key, data, template_context):
#     def pre_render(self, tag_spec, meta):
# def get_api():
# 
# Path: contentious/constants.py
# SELF_CLOSING_HTML_TAGS = ['img', 'br', 'hr', 'meta']
# 
# TREAT_CONTENT_AS_HTML_TAGS = getattr(settings,
#     'CONTENTIOUS_TREAT_CONTENT_AS_HTML_TAGS', ['div', 'select', 'ul'])


import logging
import re
from django import template
from django.template import loader, TemplateSyntaxError
from django.utils.html import escape
from ..api import api
from ..constants import (
    SELF_CLOSING_HTML_TAGS,
    TREAT_CONTENT_AS_HTML_TAGS,
)


@register.tag
def toolbar(parser, token):
    """
        Template tag that does or does not show the toolbar depending on
        the api.in_edit_mode()
    """
    parts = token.split_contents()

    templ_file_path = None
    if len(parts) == 2:
        templ_file_path = parts[1].strip('\"')
    elif len(parts) > 2:
        raise TemplateSyntaxError("%s tag expects either none or a single argument." % templ_tag_name)

    return ToolbarTag(templ_file_path)


class ToolbarTag(template.Node):
    """
        Tag only rendering the content (default or customised) if
        api.in_edit_mode() returns `False`
    """
    DEFAULT_TEMPL_PATH = "contentious/toolbar.html"

    def __init__(self, templ_file_path=None):
        self.templ_file_path = templ_file_path or self.DEFAULT_TEMPL_PATH

    def render(self, context):

# Path: contentious/api.py
# class ContentiousInterface(object):
#     def in_edit_mode(self, template_context):
#     def get_content_data(self, key, template_context):
#     def save_content_data(self, key, data, template_context):
#     def pre_render(self, tag_spec, meta):
# def get_api():
# 
# Path: contentious/constants.py
# SELF_CLOSING_HTML_TAGS = ['img', 'br', 'hr', 'meta']
# 
# TREAT_CONTENT_AS_HTML_TAGS = getattr(settings,
#     'CONTENTIOUS_TREAT_CONTENT_AS_HTML_TAGS', ['div', 'select', 'ul'])


# Path: contentious/templatetags/contentious.py
import logging
import re
from django import template
from django.template import loader, TemplateSyntaxError
from django.utils.html import escape
from ..api import api
from ..constants import (
    SELF_CLOSING_HTML_TAGS,
    TREAT_CONTENT_AS_HTML_TAGS,
)



@register.tag
def toolbar(parser, token):
    """
        Template tag that does or does not show the toolbar depending on
        the api.in_edit_mode()
    """
    parts = token.split_contents()

    templ_file_path = None
    if len(parts) == 2:
        templ_file_path = parts[1].strip('\"')
    elif len(parts) > 2:
        raise TemplateSyntaxError("%s tag expects either none or a single argument." % templ_tag_name)

    return ToolbarTag(templ_file_path)


class ToolbarTag(template.Node):
    """
        Tag only rendering the content (default or customised) if
        api.in_edit_mode() returns `False`
    """
    DEFAULT_TEMPL_PATH = "contentious/toolbar.html"

    def __init__(self, templ_file_path=None):
        self.templ_file_path = templ_file_path or self.DEFAULT_TEMPL_PATH

    def render(self, context):

        if not api.in_edit_mode(context):