Mercurial > libervia-web
diff libervia/server/tasks/implicit/task_js_modules.py @ 1259:0b269d4a46a3
task (js_modules): handle `extra_init`:
if `extra_init` is found in module metadata's `brython_map`, it is added at the end of the
generated module, and `{build_dir}` is replaced by actual build dir if present.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 03 May 2020 19:32:20 +0200 |
parents | 780dbc2f4853 |
children | 10748aa888a9 |
line wrap: on
line diff
--- a/libervia/server/tasks/implicit/task_js_modules.py Sun May 03 19:28:14 2020 +0200 +++ b/libervia/server/tasks/implicit/task_js_modules.py Sun May 03 19:32:20 2020 +0200 @@ -58,6 +58,7 @@ module_data['path'] = Path('node_modules') / js_path.strip(' /') export = module_data.get('export') or [module_name] export_objects = '\n'.join(f'{e} = window.{e}' for e in export) + extra_kwargs = {"build_dir": C.BUILD_DIR} with module_path.open('w') as f: f.write(f"""\ @@ -67,5 +68,5 @@ load("{Path('/').joinpath(C.BUILD_DIR, module_data['path'])}") {export_objects} -{module_data.get('extra_init', '')} +{module_data.get('extra_init', '').format(**extra_kwargs)} """)