# 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,
)

# CONTENTIOUS

register = template.Library()


@register.tag
def editable(parser, token):
    """ Template tag which allows an HTML element to be editable.
        Allows editing of the contents of the tag and/or any of the attributes.
        Renders with a whole load of magic data-x attributes for edit mode, or
        just renders the tag 'normally' otherswise.  If the tag has not been
        edited (i.e. there's no object in the DB for it) then the default
        attributes specified in the tag are used along with the contents of the
        template tag as the contents of the HTML tag.
    """
    parts = token.split_contents()
    templ_tag_name = parts[0]
    html_tag_name = parts[1] #this cannot be a variable because we need to know what it is *now*
    key = parser.compile_filter(parts[2])
    kwargs = convert_kwarg_strings_to_kwargs(parts[3:], parser, templ_tag_name)

    try:
        editables = kwargs.pop("editable") #take out the list of editable things
    except KeyError:
        raise TemplateSyntaxError("%s tag expects an 'editable' kwarg." % templ_tag_name)

    optionals = kwargs.pop("optional", None)
    extra = kwargs.pop("extra", None) #take out the 'extra' info, if given
    #everything else remaining in kwargs should be the attributes for the HTML tag

# 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,
)


# CONTENTIOUS

register = template.Library()


@register.tag
def editable(parser, token):
    """ Template tag which allows an HTML element to be editable.
        Allows editing of the contents of the tag and/or any of the attributes.
        Renders with a whole load of magic data-x attributes for edit mode, or
        just renders the tag 'normally' otherswise.  If the tag has not been
        edited (i.e. there's no object in the DB for it) then the default
        attributes specified in the tag are used along with the contents of the
        template tag as the contents of the HTML tag.
    """
    parts = token.split_contents()
    templ_tag_name = parts[0]
    html_tag_name = parts[1] #this cannot be a variable because we need to know what it is *now*
    key = parser.compile_filter(parts[2])
    kwargs = convert_kwarg_strings_to_kwargs(parts[3:], parser, templ_tag_name)

    try:
        editables = kwargs.pop("editable") #take out the list of editable things
    except KeyError:
        raise TemplateSyntaxError("%s tag expects an 'editable' kwarg." % templ_tag_name)

    optionals = kwargs.pop("optional", None)
    extra = kwargs.pop("extra", None) #take out the 'extra' info, if given
    #everything else remaining in kwargs should be the attributes for the HTML tag

    if html_tag_name in SELF_CLOSING_HTML_TAGS: