Beispiel #1
0
def render_common(template_name, obj, filename, version):
    if settings.COMPRESS:
        filename = get_output_filename(filename, version)

    context = obj.get("extra_context", {})
    context["url"] = media_url(filename)

    return template.loader.render_to_string(template_name, context)
Beispiel #2
0
    def render(self, context):
        js_name = template.Variable(self.name).resolve(context)

        try:
            js = settings.COMPRESS_JS[js_name]
        except KeyError:
            return '' # fail silently, do not return anything if an invalid group is specified
        
        if 'external_urls' in js:
            r = ''
            for url in js['external_urls']:
                r += render_js(js, url)
            return r
                    
        if settings.COMPRESS:

            version = None

            if settings.COMPRESS_AUTO:
                u, version = needs_update(js['output_filename'], 
                    js['source_filenames'])
                if u:
                    filter_js(js)
            else: 
                filename_base, filename = os.path.split(js['output_filename'])
                path_name = media_root(filename_base)
                version = get_version(path_name, filename)
            if self.variable is None:
                return render_js(js, js['output_filename'], version)
            else:
                context[self.variable] = [media_url(js['output_filename'], context.get('prefix', None))]
                return ''
        else:
            # output source files
            if self.variable is None:
                r = ''
                for source_file in js['source_filenames']:
                    r += render_js(js, source_file)
                return r
            else:
                context[self.variable] = [media_url(a_js_file, context.get('prefix', None)) for a_js_file in js['source_filenames']]
                return ''
Beispiel #3
0
def render_common(template_name, obj, filename, version):
    if settings.COMPRESS:
        filename = get_output_filename(filename, version)

    context = obj.get('extra_context', {})
    if filename.startswith('http://'):
        context['url'] = filename
    else:
        context['url'] = media_url(filename)
        
    return template.loader.render_to_string(template_name, context)
Beispiel #4
0
def render_common(template_name, obj, filename, version):
    if settings.COMPRESS:
        filename = get_output_filename(filename, version)

    context = obj.get('extra_context', {})
    if filename.startswith('http://'):
        context['url'] = filename
    else:
        context['url'] = media_url(filename)

    return template.loader.render_to_string(template_name, context)
def render_common(template, obj, filename, version):
    if settings.COMPRESS:
        filename = get_output_filename(filename, version)

    context = obj.get('extra_context', {})
    prefix = context.get('prefix', None)
    if filename.startswith('http://'):
        context['url'] = filename
    else:
        context['url'] = media_url(filename, prefix)
        
    #return template.loader.render_to_string(template_name, context)
    return template.replace("{{ url }}", context['url'])
Beispiel #6
0
def render_common(template_name, obj, filename, version):
    if settings.COMPRESS:
        filename = get_output_filename(filename, version)

    context = obj.get('extra_context', {})
    if settings.COMPRESS_VERSION and version is not None:
        context.update({"version": version})
    prefix = context.get('prefix', None)
    if filename.startswith('http://'):
        context['url'] = filename
    else:
        context['url'] = media_url(filename, prefix)
        
    return template.loader.render_to_string(template_name, context)
def render_common(template_name, obj, filename, version):
    if settings.COMPRESS:
        filename = get_output_filename(filename, version)

    context = obj.get('extra_context', {})
    prefix = context.get('prefix', None)
    if filename.startswith('http://'):
        context['url'] = filename
    else:
        context['url'] = media_url(filename, prefix)
    
    if not settings.COMPRESS:
        # append querystring version when not compressing files
        context['url'] = '%s?%s' % (context['url'], get_version([filename]))
        
    return template.loader.render_to_string(template_name, context)