mirror of https://github.com/amol-/dukpy.git
added webassets TypeScript filter
This commit is contained in:
parent
19c9db7db9
commit
2347d8a09f
13
README.rst
13
README.rst
|
@ -56,6 +56,19 @@ The TypeScript compiler can be used through the
|
|||
|
||||
Currently the compiler has built-in options and doesn't accept additional ones,
|
||||
|
||||
The DukPY based TypeScript compiler also provides a WebAssets (
|
||||
http://webassets.readthedocs.org/en/latest/ ) filter to automatically
|
||||
compile ES6 code in your assets pipeline. You register this filter as
|
||||
``typescript`` within WebAssets using:
|
||||
|
||||
.. code:: python
|
||||
|
||||
from webassets.filter import register_filter
|
||||
from dukpy.webassets import TypeScript
|
||||
|
||||
register_filter(TypeScript)
|
||||
|
||||
Which makes the filter available with the ``typescript`` name.
|
||||
|
||||
EcmaScript6 BabelJS Transpiler
|
||||
------------------------------
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from .babelfilter import BabelJS
|
||||
from .typescriptfilter import TypeScript
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, print_function
|
||||
from webassets.filter import Filter
|
||||
|
||||
import dukpy
|
||||
|
||||
|
||||
__all__ = ('TypeScript', )
|
||||
|
||||
|
||||
class TypeScript(Filter):
|
||||
name = 'typescript'
|
||||
max_debug_level = None
|
||||
|
||||
def setup(self):
|
||||
super(TypeScript, self).setup()
|
||||
|
||||
def input(self, _in, out, **kw):
|
||||
src = dukpy.typescript_compile(_in.read())
|
||||
out.write(src['code'])
|
2
setup.py
2
setup.py
|
@ -18,7 +18,7 @@ setup(
|
|||
version='0.0.1',
|
||||
description='Simple JavaScript interpreter for Python',
|
||||
long_description=README,
|
||||
keywords='javascript compiler babeljs coffeescript',
|
||||
keywords='javascript compiler babeljs coffeescript typescript',
|
||||
author='Alessandro Molina',
|
||||
author_email='alessandro.molina@axant.it',
|
||||
url='https://github.com/amol-/dukpy',
|
||||
|
|
Loading…
Reference in New Issue