def main(template_path, output=None, data_path=None):
    """Convert a jinja2 template to a JavaScript module.

    template_path (Path): Path to .jijna file.
    output (Optional[Path]): Path to output .js module (stdout if unset).
    data_path (Optional[Path]): Optional JSON or YAML file with additional data
        to be included in the JS module as the exported variable DATA.
    """
    data = "{}"
    if data_path is not None:
        if data_path.suffix in (".yml", ".yaml"):
            data = srsly.read_yaml(data_path)
        else:
            data = srsly.read_json(data_path)
        data = srsly.json_dumps(data)  # dump and load for compactness
    template_path = Path(template_path)
    tpl_file = template_path.parts[-1]
    compiler = JinjaToJS(template_path.parent, tpl_file, js_module_format="es6")
    header = f"// This file was auto-generated by {__file__} based on {tpl_file}"
    data_str = f"export const DATA = {data}"
    result = compiler.get_output()
    if output is not None:
        with output.open("w", encoding="utf8") as f:
            f.write(f"{header}\n{result}\n{data_str}")
        print(f"Updated {output.parts[-1]}")
    else:
        print(result)
Convert a jinja2 template to a JavaScript module.

    template_path (Path): Path to .jijna file.
    output (Optional[Path]): Path to output .js module (stdout if unset).
    data_path (Optional[Path]): Optional JSON or YAML file with additional data
        to be included in the JS module as the exported variable DATA.
    
website/setup/jinja_to_js.py