Skip to main content

Task manager similar to gulp for the processing of static files.

Working with Flask-Gulp

Setting up Flask-Gulp is quite easy. Here is an example:

from flask_gulp import Static

static = Static(app)

This allows to add tasks with the task decorator:

@static.task('coffee')
def coffee_task():
    src(r'static/coffee/**/*.coffee')\
        .pipe(coffee(bare=True))\
        .pipe(dest(output='static/js/'))

The src function is provided as a global to the task function scope along with all the extensions.

As you can see, the workflow is similar to gulp.

The js and css functions

Inspired by Flask-Funnel, the js and css functions are provided to the application context in order to generate the corresponding links:

<head>
    <!-- ... -->
    {{ css('less') }}
</head>
<body>
   <!-- ... -->
   {{ js('coffee', 'cjsx') }}
</body>

Each one receives multiple tasks names and generate the links to the generated files.

Extensions

Flask-Gulp comes shiped with four extensions, coffee, cjsx, less and dest. The first ones accept an executable setting, which holds the corresponding binary location, the default is to call it directly.

To add new extensions use the decorator provided with Flask-Gulp:

from flask_gulp.extensions import extension

@extension
def cjsx(resources):
    command = ['cjsx', '-c', '-s']
    bare = cjsx.settings.get('bare')
    if bare:
        command += ['-b']
    for filename, data in resources:
        process = subprocess.Popen(command,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        out, err = process.communicate(data)
        if process.returncode:
            yield None, err
        else:
            dest = replaceExt(filename, '.js')
            yield dest, out

Each extension receive an iterable object which yields the name and content of each file. The function must return an iterable object with the same format for resulting files. Returning the new file name as None will be interpreted as an error.

The variable <function_name>.settings holds a dictionary with the keywords provided in the extension initialization, for instance cjsx(bare=True).

Release files for Flask-Gulp 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Gulp 0.3.0
File Size Uploaded
Flask-Gulp-0.3.0.tar.gz 5.8 kB Details

Release files / Flask-Gulp-0.3.0.tar.gz

Download URL Flask-Gulp-0.3.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a8dceb97fb5466b94c3c28748ca9b7389524bf499e95b2f29263c425df76ba77
BLAKE2b-256 checksum
How to use checksums
db2ce15d2e6d71be874391d20b16ca536df027b4a6190053f517c39f5c95ef7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.8

1 release file

0.2.6

1 release file

0.2.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page