transpilers¶
Base transpiler components.
- render_static.transpilers.base.to_js(value)[source]¶
Default javascript transpilation function for values. Simply adds quotes if it’s a string and falls back on json.dumps() for non-strings and non- numerics.
- render_static.transpilers.base.to_js_datetime(value)[source]¶
A javascript value transpilation function that transpiles python dates and datetimes to javascript Date objects instead of strings. To use this function in any of the transpilation routines pass it to the to_javascript parameter on any of the template tags:
{% ... to_javascript="render_static.transpilers.to_js_datetime" %}
- class render_static.transpilers.base.CodeWriter[source]¶
Bases:
objectA base class that provides basic code writing functionality. This class implements a simple indentation/newline scheme that deriving classes may use.
- classmethod __new__(*args, **kwargs)¶
- class render_static.transpilers.base.Transpiler[source]¶
Bases:
CodeWriterAn abstract base class for JavaScript generator types. This class defines a basic generation API, and implements configurable indentation/newline behavior. It also offers a toggle for ES5/ES6 mode that deriving classes may use.
To use this class derive from it and implement include_target() and visit().
- classmethod __new__(*args, **kwargs)¶
- property Transpiler.context¶
The base template render context passed to overrides. Includes:
transpiler: The transpiler instance