Skip to content

Commit

Permalink
Switch from "6to5" to "Babel"
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Fedoseev committed Feb 18, 2015
1 parent 80f303b commit d789b69
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ matrix:
before_install:
- npm install -g coffee-script
- npm install -g [email protected]
- npm install -g [email protected]
- npm install -g [email protected]
- gem install sass --version 3.3.14
- gem install compass --version 1.0.1
install:
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Dev
* ``LESS_EXECUTABLE``
- ``-C`` (``--no-cache``) flag is removed from SASS/SCSS compilers
- Add ``STATIC_PRECOMPILER_LIST_FILES`` setting
- Add `6to5 <https://6to5.org/>`_ compiler
- Add `Babel <https://babeljs.io>`_ compiler

0.8
===
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Django Static Precompiler
=========================

Django Static Precompiler provides template tags to compile CoffeeScript, SASS / SCSS and LESS.
Django Static Precompiler provides template tags to compile CoffeeScript, SASS / SCSS, LESS, and Babel.
It works with both inline code and external files.

.. image:: https://travis-ci.org/andreyfedoseev/django-static-precompiler.svg?branch=master
Expand Down Expand Up @@ -101,7 +101,7 @@ General settings

STATIC_PRECOMPILER_COMPILERS = (
'static_precompiler.compilers.CoffeeScript',
'static_precompiler.compilers.ES6To5',
'static_precompiler.compilers.Babel',
'static_precompiler.compilers.SASS',
'static_precompiler.compilers.SCSS',
'static_precompiler.compilers.LESS',
Expand Down Expand Up @@ -161,16 +161,16 @@ Example::
)


6to5
----
Babel
-----

``executable``
Path to 6to5 compiler executable. Default: ``"6to5"``.
Path to Babel compiler executable. Default: ``"babel"``.

Example::

STATIC_PRECOMPILER_COMPILERS = (
('static_precompiler.compilers.ES6To5', {"executable": "/usr/bin/6to5"}),
('static_precompiler.compilers.Babel', {"executable": "/usr/bin/babel"}),
)


Expand Down
2 changes: 1 addition & 1 deletion provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

sudo npm install -g [email protected]
sudo npm install -g [email protected]
sudo npm install -g [email protected]
sudo npm install -g [email protected]


##############
Expand Down
2 changes: 1 addition & 1 deletion static_precompiler/compilers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
from static_precompiler.compilers.coffeescript import CoffeeScript
from static_precompiler.compilers.es6to5 import ES6To5
from static_precompiler.compilers.babel import Babel
from static_precompiler.compilers.scss import SASS, SCSS
from static_precompiler.compilers.less import LESS
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from static_precompiler.utils import run_command


class ES6To5(BaseCompiler):
class Babel(BaseCompiler):

name = "es6"
name = "babel"
input_extension = "es6"
output_extension = "js"

def __init__(self, executable="6to5"):
def __init__(self, executable="babel"):
self.executable = executable
super(ES6To5, self).__init__()
super(Babel, self).__init__()

def compile_file(self, source_path):
return self.compile_source(self.get_source(source_path))
Expand Down
2 changes: 1 addition & 1 deletion static_precompiler/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

COMPILERS = getattr(settings, "STATIC_PRECOMPILER_COMPILERS", (
"static_precompiler.compilers.CoffeeScript",
"static_precompiler.compilers.ES6To5",
"static_precompiler.compilers.Babel",
"static_precompiler.compilers.SASS",
"static_precompiler.compilers.SCSS",
"static_precompiler.compilers.LESS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# coding: utf-8
from static_precompiler.compilers.es6to5 import ES6To5
from static_precompiler.compilers.babel import Babel
from static_precompiler.exceptions import StaticCompilationError
from .test_coffeescript import clean_javascript
import pytest


def test_compile_file():
compiler = ES6To5()
compiler = Babel()

assert clean_javascript(compiler.compile_file("scripts/test.es6")) == """"use strict";\nconsole.log("Hello, World!");"""


def test_compile_source():
compiler = ES6To5()
compiler = Babel()

assert clean_javascript(compiler.compile_source('console.log("Hello, World!");')) == """"use strict";\nconsole.log("Hello, World!");"""

Expand Down

0 comments on commit d789b69

Please sign in to comment.