Esempio n. 1
0
 def render_css(self, package, path):
     template_name = package.template_name or "pipeline/css.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/css'),
         'url': mark_safe(staticfiles_storage.url(path))
     })
     return render_to_string(template_name, context)
Esempio n. 2
0
 def render_js(self, package, path):
     template_name = package.template_name or "pipeline/js.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/javascript'),
         'url': staticfiles_storage.url(path)
     })
     return render_to_string(template_name, context)
Esempio n. 3
0
 def render_css(self, package, path):
     template_name = package.template_name or "pipeline/css.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/css'),
         'url': mark_safe(staticfiles_storage.url(path))
     })
     return render_to_string(template_name, context)
Esempio n. 4
0
def render_js(package, path):  # lint-amnesty, pylint: disable=missing-function-docstring
    template_name = package.template_name or "mako/js.html"
    context = package.extra_context
    context.update({
        'type': guess_type(path, 'text/javascript'),
        'url': try_staticfiles_lookup(path)
    })
    return render_to_string(template_name, context)
 def render_js(self, package, path):
     template_name = package.template_name or "pipeline/js.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/javascript'),
         'url': staticfiles_storage.url(path)
     })
     return render_to_string(template_name, context)
Esempio n. 6
0
def render_js(package, path):
    template_name = package.template_name or "mako/js.html"
    context = package.extra_context
    context.update({
        'type': guess_type(path, 'text/javascript'),
        'url': try_staticfiles_lookup(path)
    })
    return render_to_string(template_name, context)
Esempio n. 7
0
 def render_js(self, package, path):
     """
     Override render_js from django-pipline so that js file urls are based on the applied theme
     """
     template_name = package.template_name or "pipeline/js.html"
     context = package.extra_context
     context.update({"type": guess_type(path, "text/javascript"), "url": mark_safe(get_static_file_url(path))})
     return render_to_string(template_name, context)
Esempio n. 8
0
 def render_css(self, package, path):
     template_name = package.template_name or "pipeline/css.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/css'),
         'url': self.get_url(path)
     })
     return render_to_string(template_name, context)
Esempio n. 9
0
 def render_css(self, package, path):
     template_name = package.template_name or "pipeline/css.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/css'),
         'url': self.get_url(path)
     })
     return render_to_string(template_name, context)
Esempio n. 10
0
def render_js(package, path):
    template_name = package.template_name or "mako/js.html"
    context = package.extra_context
    context.update({
        'type': guess_type(path, 'text/javascript'),
        'url': try_staticfiles_lookup(path)
    })
    return render_to_string(template_name, context)
Esempio n. 11
0
 def render_js(self, package, path):
     template_name = package.template_name or "pipeline/js.jinja"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/javascript'),
         'url': staticfiles_storage.url(path)
     })
     template = self.environment.get_template(template_name)
     return template.render(context)
Esempio n. 12
0
 def render_js(self, package, path):
     template_name = package.template_name or "pipeline/js.jinja"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/javascript'),
         'url': staticfiles_storage.url(path)
     })
     template = self.environment.get_template(template_name)
     return template.render(context)
Esempio n. 13
0
 def render_js(self, package, path):
     template_name = package.template_name or "pipeline/js_default.html"
     modified = staticfiles_storage.modified_time(path).timestamp()
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/javascript'),
         'url': mark_safe(staticfiles_storage.url(path)),
         'modified': int(modified),
     })
     return loader.render_to_string(template_name, context)
Esempio n. 14
0
def render_css(package, path):
    template_name = package.template_name or "mako/css.html"
    context = package.extra_context

    url = try_staticfiles_lookup(path)
    context.update({
        'type': guess_type(path, 'text/css'),
        'url': url,
    })
    return render_to_string(template_name, context)
Esempio n. 15
0
    def _render_css(path):
        template_name = package.template_name or "pipeline/css.jinja"

        context = package.extra_context
        context.update({
            'type': guess_type(path, 'text/css'),
            'url': staticfiles_storage.url(path)
        })

        return render_to_string(template_name, context)
Esempio n. 16
0
    def _render_css(path):
        template_name = package.template_name or "pipeline/css.jinja"

        context = package.extra_context
        context.update({
            'type': guess_type(path, 'text/css'),
            'url': staticfiles_storage.url(path)
        })

        return render_to_string(template_name, context)
Esempio n. 17
0
def render_css(package, path):
    template_name = package.template_name or "mako/css.html"
    context = package.extra_context

    url = try_staticfiles_lookup(path)
    context.update({
        'type': guess_type(path, 'text/css'),
        'url': url,
    })
    return render_to_string(template_name, context)
Esempio n. 18
0
 def render_js(self, package, path):
     """
     Override render_js from django-pipline so that js file urls are based on the applied theme
     """
     template_name = package.template_name or "pipeline/js.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/javascript'),
         'url': mark_safe(get_static_file_url(path))
     })
     return render_to_string(template_name, context)
Esempio n. 19
0
    def _render_css(path):
        template_name = package.template_name or "pipeline/css.jinja"

        context = package.extra_context
        context.update({
            'type': guess_type(path, 'text/css'),
            'url': staticfiles_storage.url(path)
        })

        template = ctx.environment.get_template(template_name)
        return template.render(context)
Esempio n. 20
0
 def render_css(self, package, path):
     """
     Override render_css from django-pipline so that stylesheets urls are based on the applied theme
     """
     template_name = package.template_name or "pipeline/css.html"
     context = package.extra_context
     context.update({
         'type': guess_type(path, 'text/css'),
         'url': mark_safe(get_static_file_url(path))
     })
     return render_to_string(template_name, context)
Esempio n. 21
0
    def _render_css(path):
        template_name = package.template_name or "pipeline/css.jinja"

        context = package.extra_context
        context.update({
            'type': guess_type(path, 'text/css'),
            'url': staticfiles_storage.url(path)
        })

        template = ctx.environment.get_template(template_name)
        return template.render(context)
Esempio n. 22
0
def render_css(package, path, raw=False):  # lint-amnesty, pylint: disable=missing-function-docstring
    template_name = package.template_name or "mako/css.html"
    context = package.extra_context

    url = try_staticfiles_lookup(path)
    if raw:
        url += "?raw"
    context.update({
        'type': guess_type(path, 'text/css'),
        'url': url,
    })
    return render_to_string(template_name, context)
Esempio n. 23
0
    def render(self, path):
        """Render the HTML tag."""
        if not self.package.template_name:
            template_name = {"js": "pipeline/js.jinja", "css": "pipeline/css.jinja"}[self.package_type]
        else:
            template_name = self.package.template_name

        mimetype = {"js": "text/javascript", "css": "text/css"}[self.package_type]

        context = self.package.extra_context
        context.update({"type": guess_type(path, mimetype), "url": staticfiles_storage.url(path)})

        env = Environment(loader=self.loader)
        tpl = env.get_template(template_name)
        return tpl.render(**context)
Esempio n. 24
0
    def render(self, path):
        """Render the HTML tag."""
        if not self.package.template_name:
            template_name = {
                'js': 'pipeline/js.jinja',
                'css': 'pipeline/css.jinja',
            }[self.package_type]
        else:
            template_name = self.package.template_name

        mimetype = {
            'js': 'text/javascript',
            'css': 'text/css',
        }[self.package_type]

        context = self.package.extra_context
        context.update({
            'type': guess_type(path, mimetype),
            'url': staticfiles_storage.url(path)
        })

        env = Environment(loader=self.loader)
        tpl = env.get_template(template_name)
        return tpl.render(**context)
Esempio n. 25
0
    def render(self, path):
        """Render the HTML tag."""
        if not self.package.template_name:
            template_name = {
                'js': 'pipeline/js.jinja',
                'css': 'pipeline/css.jinja',
            }[self.package_type]
        else:
            template_name = self.package.template_name

        mimetype = {
            'js': 'text/javascript',
            'css': 'text/css',
        }[self.package_type]

        context = self.package.extra_context
        context.update({
            'type': guess_type(path, mimetype),
            'url': staticfiles_storage.url(path)
        })

        env = Environment(loader=self.loader)
        tpl = env.get_template(template_name)
        return tpl.render(**context)
Esempio n. 26
0
 def test_guess_type(self):
     self.assertEqual('text/css', guess_type('stylesheet.css'))
     self.assertEqual('text/coffeescript', guess_type('application.coffee'))
     self.assertEqual('text/less', guess_type('stylesheet.less'))
Esempio n. 27
0
 def render_css(self, package, path):
     template_name = package.template_name or "pipeline/css.html"
     context = package.extra_context
     context.update({"type": guess_type(path, "text/css"), "url": staticfiles_storage.url(path)})
     return render_to_string(template_name, context)