Bigpipe Response class
BigpipeResponse object is a standard django 'StreamingHttpResponse'
class BigpipeResponse(StreamingHttpResponse):def __init__(self, request,render_type=RenderType.TEMPLATE,render_source=None,render_context={},pagelets=[],js_dependencies=[],scss_dependencies=[],i18n_dependencies=[],render_options: BigpipeRenderOptions = None):...
Constructor arguments:
render_source
what will be rendered back to the browser.
therender_sourcecan be any resource depends on theprocessorthat processes it.
processors can transform any kind of input, for more information read about processors.render_type
There are 3 types of
render_typeavailable:
TEMPLATEcall django build in render template with therender_source.
JAVASCRIPTcall the default/specific processor.
JAVASCRIPT_RENDERserver side render on the default/specific processor.render_context
(dict)when
render_typeisTEMPLATEit willl act ascontextfor django template engine.
whenrender_typeisJAVASCRIPT/JAVASCRIPT_RENDER. act asReact propsin case of default processor.js_dependencies
list of string indicating what additional
javascriptfiles are loaded in<script>tag or as alink
for more info see js/css dependencies string formatcss_dependencies
list of string indicating what additional
cssfiles are loaded in the<style>tag or as alink
for more info see js/css dependencies string formati18n_dependencies
list of regular expression string filtering django internalization strings and making them available for the client.
render_options (
BigpipeRenderOptions)js_processor_namethe processor name to process therender_sourceandjs_dependencies.
css_processor_namethe processor name to process thecss_dependencies.
i18n_processor_namethe processor name to process thei18n_dependencies.
js_bundle_link_dependenciesshould javascript link resources should be bundled or independent
css_bundle_link_dependenciesshould css link resources should be bundled or independentcss_complete_dependencies_by_jsshould include css files with the same name of javascript resources.
js_dom_bindwhat is theJavascriptDOMBindthat will link thejavascriptto theHTML.
js/css dependencies string format
the format of the dependencies is a list of filenames without the extension in the following format <@><processor_name>:<resource_name>
@when available the file will be served as a link<processor_name>:the processor name the will process the resource<resource_name>the resource name (file name without extension.)
for example:
js_processor_name=['file_1', 'file2']:
will processfile_1andfile_2with the default javascript processor.js_processor_name=['js_2:file_1', 'file2']
will processfile_1with a processor namedjs_2andfile_2with the default javascript processorcss_processor_name=['css_2:file_1', 'file2']
will processfile_1with a processor namedcss_2andfile_2with the default css processorjs_processor_name=['@file_1', 'file2']will processfile_1andfile_2with the default javascript processor. whilefile_1will be available as a link at therender_context
['js_module:React=react']will processReact=reactwith a processor namedjs_module. whilejs_moduleis a custom processor the builds a require string for webpack. for example
in order to build include string more easily we can pay the function bigpipe_response.helpers.to_include that will build the dependencies list for us.
for example:
to_include(['React=react', 'ReactDOM=react-dom'], is_link=True, processor_name=Bigpipe.get().config.processors.js_modules.name)
will result: ['@js_module:React=react', '@ReactDOM=react-dom']