mirror of
https://github.com/lektor/lektor-website.git
synced 2025-01-31 14:31:29 +01:00
a98b2fe9f9
Now that Lektor supports Python 3, we need to document this support. This change is perhaps a bit extreme: it replaces all explicit references to Python 2.7 with explicit references to Python 3.5. However, it's a good start, and it can and should be reviewed before being merged.
39 lines
658 B
Markdown
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_env_setup(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`)
|