Esempio n. 1
0
 def output(self, _in, out, **kw):
     content = _in.read()
     transformer = JSXTransformer()
     js = transformer.transform_string(content)
     out.write(self._moduleIntro())
     out.write(js)
     out.write(self._moduleOutro())
Esempio n. 2
0
 def __init__(self,
              content,
              attrs=None,
              filter_type=None,
              charset=None,
              filename=None):
     super(JSXCompiler, self).__init__(content, filter_type, filename)
     self.transformer = JSXTransformer()
Esempio n. 3
0
def jsx(filename: str) -> Response:
    # Figure out what our update time is to namespace on
    jsxfile = os.path.join(static_location, filename)
    mtime = os.path.getmtime(jsxfile)
    namespace = f'{mtime}.{jsxfile}'
    jsx = g.cache.get(namespace)
    if jsx is None:
        with open(jsxfile, 'rb') as f:
            transformer = JSXTransformer()
            jsx = transformer.transform_string(f.read().decode('utf-8'))
        # Set the cache to one year, since we namespace on this file's update time
        g.cache.set(namespace, jsx, timeout=86400 * 365)
    return Response(jsx, mimetype='application/javascript')
Esempio n. 4
0
def jsx(filename: str) -> Response:
    # Figure out what our update time is to namespace on
    jsxfile = os.path.join(static_location, filename)
    mtime = os.path.getmtime(jsxfile)
    namespace = '{}.{}'.format(mtime, jsxfile)
    jsx = g.cache.get(namespace)
    if jsx is None:
        transformer = JSXTransformer()
        f = open(jsxfile, 'r')
        jsx = transformer.transform_string(f.read())
        f.close()
        # Set the cache to one year, since we namespace on this file's update time
        g.cache.set(namespace, jsx, timeout=86400 * 365)
    return Response(jsx, mimetype='application/javascript')
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     CompilerBase.__init__(self, *args, **kwargs)
     self.transformer = JSXTransformer()
Esempio n. 6
0
 def initialize(self, path):
     self.root = os.path.abspath(path) + os.path.sep
     self.jsx = JSXTransformer()
     self.settings.setdefault('compiled_template_cache', False)
Esempio n. 7
0
 def __init__(self):
     CompilerBase.__init__(self)
     self.transformer = JSXTransformer()
Esempio n. 8
0
 def input(self, _in, out, **kw):
     content = _in.read()
     transformer = JSXTransformer()
     js = transformer.transform_string(content)
     out.write(js)