diff options
| author | tom christie tom@tomchristie.com | 2011-01-26 08:58:09 +0000 |
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-01-26 08:58:09 +0000 |
| commit | 6807cf014cb0fde611f63c64bc352038206176cc (patch) | |
| tree | b5ebd4414852bf39efdf5380c57875c91e798ee2 /flywheel/emitters.py | |
| parent | eff54c00d514e1edd74fbc789f9064d09db40b02 (diff) | |
| download | django-rest-framework-6807cf014cb0fde611f63c64bc352038206176cc.tar.bz2 | |
Added pygments_api example
Diffstat (limited to 'flywheel/emitters.py')
| -rw-r--r-- | flywheel/emitters.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/flywheel/emitters.py b/flywheel/emitters.py index 7492b07b..33375200 100644 --- a/flywheel/emitters.py +++ b/flywheel/emitters.py @@ -17,8 +17,21 @@ class BaseEmitter(object): self.resource = resource def emit(self, output=NoContent, verbose=False): - raise Exception('emit() function on a subclass of BaseEmitter must be implemented') + if output is NoContent: + return '' + + return output + +class TemplateEmitter(BaseEmitter): + media_type = None + template = None + def emit(self, output=NoContent, verbose=False): + if output is NoContent: + return '' + + return self.template.render(Context(output)) + from django import forms class JSONForm(forms.Form): |
