本文整理匯總了Python中coffin.template.Library.simple_tag方法的典型用法代碼示例。如果您正苦於以下問題:Python Library.simple_tag方法的具體用法?Python Library.simple_tag怎麽用?Python Library.simple_tag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coffin.template.Library
的用法示例。
在下文中一共展示了Library.simple_tag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Library
# 需要導入模塊: from coffin.template import Library [as 別名]
# 或者: from coffin.template.Library import simple_tag [as 別名]
from django.conf import settings
from django.contrib.sites.models import Site
from django.utils.translation import get_language_from_request, ugettext
if 'coffin' in settings.INSTALLED_APPS:
from coffin.template import Library
from jinja2 import Markup as mark_safe
else:
from django.template import Library
from django.utils.safestring import mark_safe
register = Library()
if 'coffin' in settings.INSTALLED_APPS:
register.simple_tag = register.object
def current_site_url():
"""Returns fully qualified URL (no trailing slash) for the current site."""
protocol = getattr(settings, 'MY_SITE_PROTOCOL', 'https')
port = getattr(settings, 'MY_SITE_PORT', '')
url = '%s://%s' % (protocol, settings.SITE_DOMAIN)
if port:
url += ':%s' % port
return url
@register.simple_tag
def tweet_it(request, url, title):
return mark_safe("""
<div class="twitter">