Browse Source

expose full_url() function in template context

main
Ryan Kelly 13 years ago
parent
commit
978c2f0ce7
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      hyde/ext/templates/jinja.py

+ 14
- 0
hyde/ext/templates/jinja.py View File

@@ -48,6 +48,13 @@ def content_url(context, path):
""" """
return context['site'].content_url(path) return context['site'].content_url(path)


@contextfunction
def full_url(context, path):
"""
Returns the full url given a partial path.
"""
return context['site'].full_url(path)



@contextfilter @contextfilter
def date_format(ctx, dt, fmt=None): def date_format(ctx, dt, fmt=None):
@@ -561,6 +568,7 @@ class Jinja2Template(Template):
extensions=settings['extensions']) extensions=settings['extensions'])
self.env.globals['media_url'] = media_url self.env.globals['media_url'] = media_url
self.env.globals['content_url'] = content_url self.env.globals['content_url'] = content_url
self.env.globals['full_url'] = full_url
self.env.globals['engine'] = engine self.env.globals['engine'] = engine
self.env.globals['deps'] = {} self.env.globals['deps'] = {}
self.env.filters['markdown'] = markdown self.env.filters['markdown'] = markdown
@@ -665,6 +673,12 @@ class Jinja2Template(Template):
""" """
return '{{ media_url(\'%s\') }}' % url return '{{ media_url(\'%s\') }}' % url


def get_full_url_statement(self, url):
"""
Returns the full url statement.
"""
return '{{ full_url(\'%s\') }}' % url

def render_resource(self, resource, context): def render_resource(self, resource, context):
""" """
Renders the given resource using the context Renders the given resource using the context


Loading…
Cancel
Save