Ejemplo n.º 1
0
    def setup(self):
        try:
            from jsjinja import JsJinja

            env = self.config.get("jsjinja", {}).get("env", None)
            self.jsjinja = JsJinja(env)
        except ImportError:
            raise EnvironmentError('The "jsjinja" package is not installed.')
Ejemplo n.º 2
0
    def __init__(self, environment):
        super(JsJinjaExtension, self).__init__(environment)

        # add the defaults to the environment
        environment.extend(
            jsjinja=JsJinja(self.environment)
            # generate_js=self.generate_js,
            # generate_all_templates=self.generate_all_templates,
        )
Ejemplo n.º 3
0
class JsJinja(Processor):
    def setup(self):
        try:
            from jsjinja import JsJinja

            env = self.config.get("jsjinja", {}).get("env", None)
            self.jsjinja = JsJinja(env)
        except ImportError:
            raise EnvironmentError('The "jsjinja" package is not installed.')

    def process(self, asset, lib=False, minified=True):
        processed = super(JsJinja, self).process(asset)
        if lib:
            lib_content = self.jsjinja.lib(minified)
            if asset.single:
                processed.content = lib_content + processed.content
            else:
                processed._assets = [StringAsset(lib_content)] + processed._assets
        return processed

    def process_single(self, asset):
        # print  '***********', asset, asset.content, '***********'
        asset.content = self.jsjinja.generate_source(asset.content, name=asset.source) + ";"
        return asset