#!/usr/bin/env python3 """Inject a JSON config into a script template and write the result. ego-browser scripts do not inherit environment variables or argv, so every input has to be written into the script text. This helper replaces the literal token __CFG__ in a template with the JSON config. Usage: python3 render.py """ import json import sys template, cfg_path, out_path = sys.argv[1:4] cfg = json.load(open(cfg_path, encoding="utf-8")) src = open(template, encoding="utf-8").read() assert "__CFG__" in src, "template has no __CFG__ placeholder" open(out_path, "w", encoding="utf-8").write(src.replace("__CFG__", json.dumps(cfg, ensure_ascii=False))) print("rendered", out_path)