The generators in Flourish are responsible for turning one or more source objects into output HTML.
Subclassing the generators
If you need to alter the way a page or pages are being generated, it should normally be possible to subclass one of the default generators and modify only a small part of it.
The included generators
BaseGenerator— the base class of all Flourish generators
SourceGenerator— the class for generating individual source pages
IndexGenerator— the class for generating lists of source pages
PaginatedIndexGenerator— the class for generating paginated lists of source pages
AtomGenerator— the class for generating an Atom feed
SassGenerator— the class for generating CSS files from SASS-formatted sources
CalendarGenerator— classes for generating date-based indexes
The included mixins
Adds the first of
self.source_objects to the template context as
well as all key values from that object. For example, a TOML source of:
title = 'About this site' tag = ['about', 'information'] noindex = true
would make all of
values available for use in templates.
Adds the list of source objects to the template context as
Sometimes you may want to not generate a page (for example, due to a lack of
content). To do this, raise
DoNotGenerate and the generator will skip that
page without it counting as an error.
def get_objects(self, tokens): sources = self.get_filtered_sources().filter(**tokens) if sources.count() == 0: raise self.DoNotGenerate