lektor.context.
Context
When Lektor builds sources into finished build artifacts it performs many
operations in addition to just creating the end result. For instance it needs
to perform dependency tracking, it needs to remember that there might be
associated other artifacts and more. All this information is tracked on the
Context
during a build of a single source. At a later point the builder
will look at the context to decide on further operations to perform.
The current context can be discovered by calling the get_ctx
function which will return it. If there is no artifact build ongoing then
the return value will be None
.
from lektor.context import get_ctx
ctx = get_ctx()
print('The current source is %s' % ctx.source)
Can override the base URL that is used for relative URL generation.
Can collect dependencies for a code block.
The current locale (language/territory) code for the context.
A reference to the active database pad.
A reference to the current source record.
Instructs the builder to record a new dependency for the current artifact.
A reference to the current source object.
Creates a sub-artifact of the current one.
Comments