本文整理汇总了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