lektor-website/content/docs/api/plugins/plugin/emit/contents.lr
relikd f5327b786d
fix on_setup_env callback function naming (#342)
Fix typos: on_env_setup -> on_setup_env
Thank you, @relikd
2022-03-19 16:37:08 -07:00

39 lines
658 B
Markdown

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):
def on_setup_env(self, **extra):
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):
print('got %s' % foo)
```
(This assumes the plugin id is set to `my-plugin` in `setup.py`)