id summary reporter owner description type status priority milestone component version severity resolution keywords cc branch changelog apichanges internalchanges
7774 Allow to set script charset in add_script martin@… martin@… "The function `add_script` in `trac.web.chrome` should allow the programmer to set a `charset` attribute for the script he/she is adding.
I wrote a small path for this:
{{{
#!diff
diff -Naur Trac-0.11.1-py2.5.egg/trac/templates/layout.html Trac-0.11.1-py2.5.egg.new/trac/templates/layout.html
--- Trac-0.11.1-py2.5.egg/trac/templates/layout.html 2008-11-03 12:08:30.000000000 +0000
+++ Trac-0.11.1-py2.5.egg.new/trac/templates/layout.html 2008-11-03 12:15:58.000000000 +0000
@@ -20,7 +20,7 @@
-
${Markup('<!--[if lt IE 7]>')}
diff -Naur Trac-0.11.1-py2.5.egg/trac/web/chrome.py Trac-0.11.1-py2.5.egg.new/trac/web/chrome.py
--- Trac-0.11.1-py2.5.egg/trac/web/chrome.py 2008-11-03 12:08:30.000000000 +0000
+++ Trac-0.11.1-py2.5.egg.new/trac/web/chrome.py 2008-11-03 12:15:43.000000000 +0000
@@ -82,7 +82,7 @@
href = href.chrome
add_link(req, 'stylesheet', href(filename), mimetype=mimetype)
-def add_script(req, filename, mimetype='text/javascript'):
+def add_script(req, filename, mimetype='text/javascript', charset='UTF-8'):
""""""Add a reference to an external javascript file to the template.
If the filename is absolute (i.e. starts with a slash), the generated link
@@ -101,7 +101,7 @@
if not filename.startswith('/'):
href = href.chrome
path = filename
- script = {'href': href(path), 'type': mimetype}
+ script = {'href': href(path), 'type': mimetype, 'charset': charset }
req.chrome.setdefault('scripts', []).append(script)
scriptset.add(filename)
}}}
" enhancement closed normal 1.0 web frontend none minor fixed add_script javascript chrome patch chrome: `add_script` takes optional charset argument (defaults to 'utf-8'). [10196]