added webassets TypeScript filter

This commit is contained in:
Simone Gasbarroni 2016-03-17 16:10:51 +01:00
parent 19c9db7db9
commit 2347d8a09f
4 changed files with 35 additions and 1 deletions

View File

@ -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
------------------------------

View File

@ -1 +1,2 @@
from .babelfilter import BabelJS
from .typescriptfilter import TypeScript

View File

@ -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'])

View File

@ -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',