Skip to main content

Buildout recipe for making files out of Mako templates

Project description Maintainability Test Coverage


A buildout recipe for making files out of Mako templates, with focus on manageability of large number of templates.

The reasons behind creating this ‘another’ template recipe for buildout are wish of having:

  • mako with all power of python and good scoping in templates,

  • simple listing of source : destinatoin mapping,

  • and collision detection.

Recipe Options

  • files: list of couples of templates and targets files paths separated by : symbol. It allow to specify if target should be executable, and to ignore a collision. Line has following format:

    source:target[:is_executable(true or false)[:collision_allowed(just a flag))]]

  • directories : list of lookup directories of the mako templates. Templates file paths are relative to these directories. (default: ${buildout:directory})

Additional options are simply forwarded to the templates, and options from all the other parts are made available through parts[<part-name>][<option-name>].

Minimal Example


parts = foo

recipe = buildout.recipe.mako_template
author = Me
files = :

echo Hello ${author}!

Will result in creation of

echo Hello Me!

Larger Example

parts = docker-compose

name = MyProject

recipe = buildout.recipe.mako_template
directories = ${buildout:directory}/templates
gateway_ports = 8080:8080
files =
    backend.dockerfile.mako  : .docker/backend.dockerfile
    frontend.dockerfile.mako : .docker/frontend.dockerfile
    gateway.dockerfile.mako  : .docker/gateway.dockerfile
    docker-compose.yaml.mako : docker-compose.yaml


    container_name: ${parts['project']['name']}_gateway
      - "${gateway_ports}"

Collision detection

Cases where one’s template target are overridden by another template are detected automatically. For example, case:

files = : :  # overwrites ``target`` form above

will result in a build fail with the message:

Target collision is detected at ' :'

Yet in some cases, it may be a desirable behavior, so it’s possible to allow overwriting by adding collision_allowed flag.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildout.recipe.mako_template-0.1.2.tar.gz (11.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page