Skip to main content

Integrates Webassets into Morepath.

Project description

Webassets | Morepath

This package is somewhat similar to more.static, which integrates bowerstatic into Morepath. It is currently not really used anywhere, so you should probably stick to more.static.

Now that you are sufficently discouraged from using more.webassets, these are the reasons it might be for you:

  • You don’t have to learn about javascript package managers (i.e. Bower).

  • You can have your assets compiled on the fly.

  • Your stylesheets are rendered at the top, your scripts at the bottom. No configuration necessary.

If you are alreay familiar with webassets: This package might not be as powerful as you’re used to. It currently has little flexibility. It’s also the first time the author uses webassets, so things might be off.

Usage

To get a basic application that serves webassets under /assets/*:

from morepath import reify
from more.webassets import WebassetsApp
from webassets import Bundle

class MyApp(WebassetsApp):

    @reify
    def webassets_bundles(self):
        return {
            'jquery': Bundle(
                'jquery.js',
                filters='jsmin',
                output='bundles/jquery.bundle.js'
            )
        }

@MyApp.path('')
class Root(object):
    pass

@MyApp.html(model=Root):
def index(self, request):
    request.include('jquery')

    return '<html><head></head><body>hello</body></html>'

This will result in the following html (formatted for readability):

<html>
    <head></head>
    <body>hello</body>
    <script type="text/javascript" src="./assets/bundles/jquery.bundle.js?1234"></script>
</html>

For it to work you need an ‘assets’ folder with a ‘jquery.js’ file in the same folder as your python file where ‘MyApp’ is defined.

Run the Tests

Install tox and run it:

pip install tox
tox

Limit the tests to a specific python version:

tox -e py27

Conventions

More Webassets follows PEP8 as close as possible. To test for it run:

tox -e pep8

More Webassets uses Semantic Versioning

Build Status

Build Status

Coverage

Project Coverage

Latests PyPI Release

Latest PyPI Release

License

more.webassets is released under the revised BSD license

Changelog

Unreleased

0.0.2 (2015-05-18)

  • Adds more checks to ensure we never serve anything outside the assets directory. [href]

0.0.1 (2015-04-29)

  • Initial Release [href]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

more.webassets-0.0.2.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

more.webassets-0.0.2-py2-none-any.whl (12.2 kB view details)

Uploaded Python 2

File details

Details for the file more.webassets-0.0.2.tar.gz.

File metadata

File hashes

Hashes for more.webassets-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1a353d0f699e6198558a7713b89180ee9ae5064532409385f8393a8769ab1604
MD5 de10eb7d2614cdc40cec7d73894b5979
BLAKE2b-256 4867d9ffa192d72808d14d547496dd1dc74722d06eb7cdf05b3bce18ee21804f

See more details on using hashes here.

File details

Details for the file more.webassets-0.0.2-py2-none-any.whl.

File metadata

File hashes

Hashes for more.webassets-0.0.2-py2-none-any.whl
Algorithm Hash digest
SHA256 29506666fa8699d808be90346f41f7484785de9ef82abbda50bb8e14a059d30a
MD5 8de3e32ec88c0e25f6c3562a841448b3
BLAKE2b-256 588147d18f0068d70eaef797499eedad1767f75d6f4e908fc3f97760d075714c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page