Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Jun 13, 2016
1 parent 921ee89 commit 06f0bac
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@

A modular plugin system for django apps.

There are 3 kinds of hooks:
There are 4 kinds of hooks:

* TemplateHook: Third-party apps will be able to insert their own code (text/html) into an app template.
* FormHook: Third-party apps will be able to insert Forms in an app view.
* ~~ViewHook~~: This is deprecated in favor of `FormHook`
* SignalHook: Connect or emit a signal by its name/id. This is the same as Django signals
except that they don't need to be pre-defined.
* TemplateHook: Third-party apps will be able to insert their own code (text/html) into a template.
* ModelHook: Third-party apps will be able to add fields and methods to a model.
* FormHook: Third-party apps will be able to insert Forms in a view.
* ~~ViewHook~~: This is deprecated in favor of FormHook
* SignalHook: Connect or emit a signal by its name/id.
This is the same as Django signals except that they don't need to be pre-defined.

## Why?

Let's say we want to render contextual information beside a record allocated in `my_main_app`.
This extra information can be provided by some third-party application: Notes, Attachments,
Comments, Followers, etc.

Adding an `{% include %}` tag to our `my_record.html` is not possible because we don't know what
to render beforehand (a note? a list of comments?) or even if any of those applications are
installed for our case/customer/project.

We can create a *TemplateHook* `{% hook 'my_contextual_info' %}` where we delegate the rendering and
content retrieval to the hooked app(s). By doing so, `my_record.html` doesn't need to be touched anymore,
no need to add more templatetags to `{% load %}` and we also make it easily reusable.
* The app does not have to be built to support plugins from the grown up.
`django-hooks` can be added as an afterthought.
* It's modular, use the hooks your app needs.
* It's is explicit, there is no magical or surprising behaviour.

## Compatibility

Expand Down

0 comments on commit 06f0bac

Please sign in to comment.