Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

lino.utils.jsgen

A framework for generating Javascript from Python.

See also Utilities for generating Javascript code.

Example in Lino utilities.

Functions

declare_vars(v)

Yields the Javascript lines that declare the given Variable v.

dict2js(d)

id2js(s)

js_line(s, *args)

obj2dict(o, attrs)

param o:

object

py2js(v[, compact])

Note that None values are rendered as null (not undefined).

register_converter(func)

Classes

Component([name])

A Component is a Variable whose value is a dict of options.

Value(value)

Variable(name, value)

VisibleComponent(name, **kwargs)

A visible component

js_code(s)

A string that py2js will represent as is, not between quotes.

lino.utils.jsgen.obj2dict(o, attrs)
Parameters:
  • o -- object

  • attrs -- space seperated string or list of strings of wanted attrs

  • kws -- existing dict of values

Returns:

dict with key:value pairs that match the object[arrts] if arrts exist in object

class lino.utils.jsgen.js_code(s)

Bases: object

A string that py2js will represent as is, not between quotes.

class lino.utils.jsgen.Component(name=None, **options)

Bases: Variable

A Component is a Variable whose value is a dict of options. Deserves more documentation.

walk()

Walk over this component and its children.

class lino.utils.jsgen.VisibleComponent(name, **kwargs)

Bases: Component, Permittable

A visible component

install_permission_handler()

Define the allow_read handler used by get_view_permission(). This must be done only once, but after having configured debug_permissions and required_roles.

lino.utils.jsgen.declare_vars(v)

Yields the Javascript lines that declare the given Variable v. If v is a Component, list, tuple or dict which contains other variables, recursively yields also the lines to declare these.

lino.utils.jsgen.py2js(v, compact=True)

Note that None values are rendered as null (not undefined).