本文整理匯總了Python中genshi.filters.Transformer.prepend方法的典型用法代碼示例。如果您正苦於以下問題:Python Transformer.prepend方法的具體用法?Python Transformer.prepend怎麽用?Python Transformer.prepend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類genshi.filters.Transformer
的用法示例。
在下文中一共展示了Transformer.prepend方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: filter_stream
# 需要導入模塊: from genshi.filters import Transformer [as 別名]
# 或者: from genshi.filters.Transformer import prepend [as 別名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'query.html':
filter_script = Transformer('//script[contains(@src, "jquery.js")]')
filter_query = Transformer('table[@class="listing tickets"]/.')
return stream | filter_script.after(
tag.script(
type="text/javascript",
src=self.env.href('chrome', 'aq', 'js', 'query.js'))) \
| filter_query.prepend('<!-- Hello -->')
return stream
示例2: filter_stream
# 需要導入模塊: from genshi.filters import Transformer [as 別名]
# 或者: from genshi.filters.Transformer import prepend [as 別名]
def filter_stream(self, req, method, filename, stream, data):
if filename == 'ticket.html':
ticket = data.get('ticket')
if ticket and ticket.exists and \
'TICKET_CREATE' in req.perm(ticket.resource):
# Find the configured buttons (anything in
# [ticket-create-buttons] that has a name like "*.tag")
options=self.config.options('ticket-create-buttons')
buttons=[]
for n, v in options:
p=n.split('.')
if len(p)==2 and p[1] == 'tag':
buttons.append(p[0])
# Create the configured buttons
for b in buttons:
tag=self.config.get('ticket-create-buttons','%s.tag' % b)
filter = Transformer(tag)
stream = stream | filter.prepend(self._create_button(b, req, ticket, data))
return stream