ctl.plugins.template
Plugin that allows you to render templates
Requirements
pip install tmpl jinja
Classes
TemplatePlugin
TemplatePlugin(ctl.plugins.copy.CopyPlugin)
render all template files from a source director into an output directory
Class Attributes
- ConfigSchema (
ConfigSchema Class
): Base plugin config schema
Instanced Attributes
These attributes / properties will be available on instances of the class
- engine (
@property
): template engine instance - tmpl_env (
@property
): template environment
Class Methods
expose_vars
def expose_vars(cls, env, plugin_config)
Loop through the files specified in the vars
plugin config property
and expose them to the config template environment
Note that this is different than the load_vars
method which will
expose the same vars to the template environment for rendering
the templates
Arguments
- env (
dict
): template environment - plugin_config (
dict
)
Returns
dict<filepath, error>
: dict of ioerrors mapped to filepath
Methods
copy_file
def copy_file(self, path, dirpath)
Copy file
Arguments
- path (
str
): relative filepath being processed - dirpath (
str
): relative dirpath being processed
execute
def execute(self, **kwargs)
Execute the plugin
overrides and calls ExecutablePlugin.execute
load_vars
def load_vars(self)
Loop through the files specified in the vars
plugin config property
and expose them to the template environment
prepare
def prepare(self, **kwargs)
Prepare plugin for execution
overrides and calls WalkDirPlugin.prepare
template_file
def template_file(self, path)
Render the template from source to output using a relative file path
Arguments
- path(
str
): relative (to source or output) template file path
TemplatePluginConfig
TemplatePluginConfig(ctl.plugins.copy.CopyPluginConfig)
Configuration schema for TemplatePlugin
Class Attributes
- engine (
Str
): template engine - vars (
List<Str>
): list of files containing template variables to import