Skip to main content

The python middleware for neuron.js

Project description

Build Status


Python utilities and middleware for neuron.js

pyneuronjs analyzes the dependencies from user defined facades according to the dependency tree, and outputs <script> tags and configurations for neuron.js

The dependency tree can be generated by neuron-package-dependency


$ pip install pyneuronjs


from pyneuronjs import Neuron

n = Neuron(
  dependency_tree=dependency_tree,  # must defined

pyneuronjs could be used either in template file or your python controller.

Here is a sample Jinja2 template file.

  • dependency_tree dict the json.loads()ed dependency tree

  • resolve function(id)= (optional) implements your own custom resolver. resolve accepts one parameter id which can be either a str of module id or a list of module ids. If a str is passed in, the method should returns the resolved absolute url of the module id. If id is a list, an url of comboed script files should be returned.

  • debug function|bool=False tells pyneuronjs whether should switch on debug mode. When on debug mode, no javascript files of dependencies will be preloaded, and the output will not be compressed.

  • if debug is callable, pyneuronjs will use the return value of method debug

  • if debug is a boolean value, and debug is true, the debug mode will be on.

  • cache dict=None if cache is defined, it should contains 3 methods:

  • cache.has(key) returns bool

  • cache.get(key) looks up and returns the cached value by key

  • cache.set(key, value) sets the value by key

  • version str only works if cache is defined. pyneuronjs will uses version to generate the key to cache the output result

module id

<name>@<version><path>  # for example: 'jquery@2.0.0/jquery.js'

n.facade(entry, data=None)

  • entry str id of the entry module

Registers a facade entry with data. pyneuronjs will

Returns ''(empty string), so you can use this method in python template


Returns ''


Returns ''


Returns str


Returns str



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

pyneuronjs-1.2.0.tar.gz (6.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page