Ticket #47: trac-ticket_notify_mail-r3697.diff
| File trac-ticket_notify_mail-r3697.diff, 4.7 KB (added by cboos, 17 years ago) |
|---|
-
trac/web/chrome.py
21 21 from markup import Markup 22 22 from markup.builder import tag 23 23 from markup.output import DocType 24 from markup.template import TemplateLoader 24 from markup.template import TemplateLoader, Template, TextTemplate 25 25 26 26 from trac import mimeview 27 27 from trac.config import * … … 413 413 if req: 414 414 data['MARKUP_DEBUG'] = req.args.get('markup_debug') 415 415 416 def load_template(self, filename, req=None, data=None ):416 def load_template(self, filename, req=None, data=None, method=None): 417 417 """Retrieve a Template and optionally preset the template data""" 418 418 if req and data: 419 419 self.populate_data(req, data) 420 420 if not self.templateloader: 421 421 self.templateloader = TemplateLoader(self.get_all_templates_dirs(), 422 422 auto_reload=self.auto_reload) 423 return self.templateloader.load(filename) 423 cls = method == 'text' and TextTemplate or Template 424 return self.templateloader.load(filename, cls=cls) 424 425 425 426 def render_response(self, req, template_name, content_type, data): 426 self.populate_data(req, data)427 428 stream = self.load_template(template_name).generate(**data)429 430 427 if content_type is None: 431 428 content_type = 'text/html' 429 doctype = {'text/html': DocType.XHTML_STRICT}.get(content_type) 432 430 method = {'text/html': 'xhtml', 433 431 'text/plain': 'text'}.get(content_type, 'xml') 434 doctype = {'text/html': DocType.XHTML_STRICT}.get(content_type) 432 433 template = self.load_template(template_name, req, data, method=method) 434 stream = template.generate(**data) 435 435 436 436 if method == 'text': 437 437 return stream.render('text') 438 return stream.render(method, doctype=doctype) 438 else: 439 return stream.render(method, doctype=doctype) -
trac/notification.py
96 96 self.config = env.config 97 97 self.db = env.get_db_cnx() 98 98 99 self.template = Chrome(self.env).load_template(self.template_name) 99 self.template = Chrome(self.env).load_template(self.template_name, 100 method='text') 100 101 self.data = {'CRLF': CRLF} 101 102 Chrome(self.env).populate_data(None, self.data) 102 103 -
templates/ticket_notify_email.txt
1 <mail xmlns:py="http://markup.edgewall.org/" py:strip=""><!--!2 3 Some notes about how to handle white-spaces in text templates:4 5 - every structure tag should be followed by a comment start: < ! - - !6 7 - every tag but the first should be preceeded by a comment end: - - >8 9 - text data following a new line will be inserted either directly,10 by first ending the comment then placing the content on the same11 line, or inserted after a newline, by first closing the comment,12 then placing the data on a line of its own.13 14 - after text data, a comment start should be started on a newline,15 which will effectively insert a newline.16 Sometimes though this is not wanted, for example when the data17 itself ends with a newline... (see $changes_body below)18 19 -->20 1 $ticket_body_hdr 21 2 $ticket_props 22 <!--! 23 --><py:choose test="ticket.new"><!--! 24 --><py:when test="True"><!--! 25 --> 3 #choose ticket.new 4 #when True 26 5 $ticket.description 27 <!--! 28 --></py:when><!--! 29 --><py:otherwise><!--! 30 --><py:if test="changes_body"><!--! 31 --> 6 #endwhen 7 #otherwise 8 #if changes_body 32 9 Changes (by $change.author): 33 10 34 $changes_body<!--! 35 --></py:if><!--! 36 --><py:if test="changes_descr"><!--! 37 --> 11 $changes_body 12 #endif 13 #if changes_descr 38 14 $changes_descr 39 15 -- 40 <!--! 41 --></py:if><!--! 42 --><py:if test="change.comment"><!--! 43 --> 44 Comment<py:if test="not changes_body"> (by $change.author)</py:if>: 16 #endif 17 #if change.comment 45 18 19 Comment${not changes_body and '(by %s)' % change.author or ''}: 20 46 21 $change.comment 47 <!--! 48 --></py:if><!--! 49 --></py:otherwise><!--! 50 --></py:choose><!--! 51 --> 22 #endif 23 #endotherwise 24 #endchoose 25 52 26 -- 53 27 Ticket URL: <$ticket.link> 54 28 $project.name <${abs_href}> 55 29 $project.descr 56 </mail>57 No newline at end of file
