예제 #1
0
 def testGetAssetTag(self):
     asset = get_test_asset()
     url = default_asset_cache.get_url(asset)
     self.assertEqual(
         Template("{% load assets %}{% get_asset asset as asset_url %}{{asset_url}}").render(Context({
             "asset": asset,
         })),
         url,
     )
 def testGetAssetTag(self):
     asset = get_test_asset()
     url = default_asset_cache.get_url(asset)
     self.assertEqual(
         Template("{% load assets %}{% get_asset asset as asset_url %}{{asset_url}}").render(Context({
             "asset": asset,
         })),
         url,
     )
 def do_url_replacement(match):
     url = match.group(1).strip()
     # Resolve relative URLs.
     url = urlparse.urljoin(host_url, url)
     # Strip off query and fragment.
     url_parts = urlparse.urlparse(url)
     # Compile static urls.
     if url.startswith(settings.STATIC_URL):
         simple_url = urlparse.urlunparse(url_parts[:3] + ("", "", "",))
         static_url = default_asset_cache.get_url(simple_url[len(settings.STATIC_URL):], force_save=True)
         url = urlparse.urlunparse(urlparse.urlparse(static_url)[:3] + url_parts[3:])
     return u"url({url})".format(
         url = url,
     )
예제 #4
0
 def do_url_replacement(match):
     url = match.group(1).strip()
     # Resolve relative URLs.
     url = urlparse.urljoin(host_url, url)
     # Strip off query and fragment.
     url_parts = urlparse.urlparse(url)
     # Compile static urls.
     if url.startswith(settings.STATIC_URL):
         simple_url = urlparse.urlunparse(url_parts[:3] + (
             "",
             "",
             "",
         ))
         static_url = default_asset_cache.get_url(
             simple_url[len(settings.STATIC_URL):],
             force_save=True)
         url = urlparse.urlunparse(
             urlparse.urlparse(static_url)[:3] + url_parts[3:])
     return "url({url})".format(url=url, )
예제 #5
0
def get_asset(src):
    return default_asset_cache.get_url(src)
예제 #6
0
def asset(src):
    """Returns the cached asset URL of the given asset."""
    url = default_asset_cache.get_url(src)
    return escape(url)
예제 #7
0
def get_asset(src):
    return default_asset_cache.get_url(src)
예제 #8
0
def asset(src):
    """Returns the cached asset URL of the given asset."""
    url = default_asset_cache.get_url(src)
    return escape(url)