本文整理匯總了Python中wishbone.event.Event.renderField方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.renderField方法的具體用法?Python Event.renderField怎麽用?Python Event.renderField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wishbone.event.Event
的用法示例。
在下文中一共展示了Event.renderField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generateEvent
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import renderField [as 別名]
def generateEvent(self, data={}, destination=None):
'''
Generates a new event.
This function can get overridden by
``wishbone.module.InputModule._generateNativeEvent``.
The provided ``data`` will be traversed in search of valid templates
which then will be rendered.
Args:
data (``data``): The payload to add to the event.
destination (None): The destination key to write the data to
Returns:
wishbone.event.Event: An event containing ``data`` as a payload.
'''
if destination in [None, "data"]:
event = Wishbone_Event(data)
event.renderField(destination, self.env_template)
else:
event = Wishbone_Event()
event.set(data, destination)
event.renderField(destination, self.env_template)
return event
示例2: test_render_field
# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import renderField [as 別名]
def test_render_field():
e = Event({"value": "Hello", "template": "{{data.value}} how are you doing?"})
assert e.get("data.template") == "{{data.value}} how are you doing?"
e.renderField("data.template")
assert e.get("data.template") == "Hello how are you doing?"