#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (C) 2010 Łukasz Langa
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""BBCode-related template tags."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from django.template import Library
from django.utils.safestring import mark_safe
from postmarkup import render_bbcode

register = Library()

@register.filter
def bbcode(text):
    """Simply encode the BBCode within the text.

    Template tag available in ``common`` app's ``bbcode`` library.

    :param text: the string to render as BBCode"""
    return mark_safe(render_bbcode(text))
