Skip to main content

Build Status

pyneuronjs

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

Install

$ pip install pyneuronjs

Usage

from pyneuronjs import Neuron

n = Neuron(
  dependency_tree=dependency_tree,  # must defined
  resolve=resolve,
  version=version,
  cache=cache,
  debug=False)

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

n.combo(id…)

Returns ''

n.css(id)

Returns ''

n.output()

Returns str

n.output_css()

Returns str

License

MIT

Release files for pyneuronjs 1.2.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 pyneuronjs 1.2.0
File Size Uploaded
pyneuronjs-1.2.0.tar.gz 6.6 kB Details

Release files / pyneuronjs-1.2.0.tar.gz

Download URL pyneuronjs-1.2.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b2a894e45a944facbe04f1201a53b7d7bc7ce9999947a00840f398afaf324bc1
BLAKE2b-256 checksum
How to use checksums
80f727b371a689a019be33af9dce589e48bbe5085cbc7551a0ec11ce43b586ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.0.1

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