Merge pull request #12999 from ankush/add_sourceurl

feat(DX): sourceURL for injected javascript
This commit is contained in:
mergify[bot] 2021-04-28 12:58:55 +00:00 committed by GitHub
commit d9e229bc14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,8 +109,9 @@ class FormMeta(Meta):
def _add_code(self, path, fieldname):
js = get_js(path)
if js:
self.set(fieldname, (self.get(fieldname) or "")
+ "\n\n/* Adding {0} */\n\n".format(path) + js)
comment = f"\n\n/* Adding {path} */\n\n"
sourceURL = f"\n\n//# sourceURL={scrub(self.name) + fieldname}"
self.set(fieldname, (self.get(fieldname) or "") + comment + js + sourceURL)
def add_html_templates(self, path):
if self.custom:
@ -145,6 +146,10 @@ class FormMeta(Meta):
if script.view == 'Form':
form_script += script.script
file = scrub(self.name)
form_script += f"\n\n//# sourceURL={file}__custom_js"
list_script += f"\n\n//# sourceURL={file}__custom_list_js"
self.set("__custom_js", form_script)
self.set("__custom_list_js", list_script)