示例#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)
示例#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)
示例#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)
示例#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)
示例#6
0
文件: __init__.py 项目: saadow123/1
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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
    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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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'))
示例#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)