2015-12-19 14:52:17 +01:00
|
|
|
title: emit
|
|
|
|
---
|
|
|
|
type: method
|
|
|
|
---
|
|
|
|
signature: event, **extra
|
|
|
|
---
|
|
|
|
summary: Emits a plugin specific event.
|
|
|
|
---
|
|
|
|
body:
|
|
|
|
|
|
|
|
This method can be used to emit an event that other plugins can hook. The
|
|
|
|
event name is prefixed with the plugin ID.
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```python
|
|
|
|
from lektor.pluginsystem import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
class MyPlugin(Plugin):
|
|
|
|
|
2022-03-20 00:37:08 +01:00
|
|
|
def on_setup_env(self, **extra):
|
2015-12-19 14:52:17 +01:00
|
|
|
self.emit('setup', foo=42)
|
|
|
|
```
|
|
|
|
|
|
|
|
Another plugin can then hook this:
|
|
|
|
|
|
|
|
```python
|
|
|
|
from lektor.pluginsystem import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
class MyPlugin(Plugin):
|
|
|
|
|
|
|
|
def on_my_plugin_setup(self, foo, **extra):
|
2016-06-03 06:54:49 +02:00
|
|
|
print('got %s' % foo)
|
2015-12-19 14:52:17 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
(This assumes the plugin id is set to `my-plugin` in `setup.py`)
|