Ticket #7774 (new enhancement)
Opened 2 months ago
Allow to set script charset in add_script
| Reported by: | martin@… | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | web frontend | Version: | none |
| Severity: | normal | Keywords: | add_script javascript chrome |
| Cc: |
Description
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:
-
trac/templates/layout.html
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
old new 20 20 <link type="application/opensearchdescription+xml" rel="search" 21 21 href="${href.search('opensearch')}" title="Search $project.name"/> 22 22 </py:if> 23 <script py:for="script in chrome.scripts" 23 <script py:for="script in chrome.scripts" charset="${script.charset}" 24 24 type="${script.type}" src="${script.href}"></script> 25 25 ${Markup('<!--[if lt IE 7]>')} 26 26 <script type="text/javascript" src="${chrome.htdocs_location}js/ie_pre7_hacks.js"></script> -
Trac-0.11.1-py2.5.egg
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
old new 82 82 href = href.chrome 83 83 add_link(req, 'stylesheet', href(filename), mimetype=mimetype) 84 84 85 def add_script(req, filename, mimetype='text/javascript' ):85 def add_script(req, filename, mimetype='text/javascript', charset='UTF-8'): 86 86 """Add a reference to an external javascript file to the template. 87 87 88 88 If the filename is absolute (i.e. starts with a slash), the generated link … … 101 101 if not filename.startswith('/'): 102 102 href = href.chrome 103 103 path = filename 104 script = {'href': href(path), 'type': mimetype }104 script = {'href': href(path), 'type': mimetype, 'charset': charset } 105 105 106 106 req.chrome.setdefault('scripts', []).append(script) 107 107 scriptset.add(filename)
Attachments
Note: See
TracTickets for help on using
tickets.


