Flourish API: flourish.generators.base.SourceGenerator
SourceGenerator
is the class for generating individual source pages.
Other than as noted below, it behaves the same as
BaseGenerator
.
from flourish.generators import base
PATHS = (
...
base.SourceGenerator(
name = 'source',
path = '/#slug',
),
...
)
Class attributes
limit
— This generator should return no more thanlimit
sources.order_by
— This generator should sort matching sources in this way. Default value isNone
. However, as this generator is meant for generating single sources, it is also meaningless in this case.sources_exclude
— This generator should exclude sources that match this filter. Default value isNone
.sources_filter
— This generator should only use sources that match this filter; see Filtering down to specific sources. Default value isNone
.template_name
— This generator should use this template when rendering the content. Default value ispage.html
.
Context variables
current_url
— the URL of this pageobjects
— a list of all matching source objects for the current URLpage
— the source object matching the current URLsite
— a dictionary containing all of the keys in the_site.toml
configuration file...
— every key that has been set in the matching source object
Mixins
PageGenerator
includes the features of
PageContextMixin
.
Generator method flow
get_template_name()
This method is altered to returns the value of template_name
unless the
page source has set the key page_type
, in which case it returns the value of
page_type
with ".html" appended, or if the key template
has been set, when
that value is returned unaltered.
For example, the following TOML would give a template name of photo.html
:
title = 'Grand Canyon'
page_type = 'photo'
...
whereas this would give a template name of broken
:
title = 'Grand Canyon'
page_type = 'photo'
template = 'broken'
...