Skip to main content
https://img.shields.io/pypi/v/buildout.recipe.mako_template.svg https://img.shields.io/travis/enkidulan/buildout.recipe.mako_template.svg Maintainability Test Coverage

buildout.recipe.mako_template

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

buildout.cfg:

[buildout]
parts = foo


[foo]
recipe = buildout.recipe.mako_template
author = Me
files = foo_1.sh.mako : foo_1.sh

foo_1.sh.mako:

echo Hello ${author}!

Will result in creation of foo_1.sh:

echo Hello Me!

Larger Example

[buildout]
parts = docker-compose

[project]
name = MyProject

[docker-compose]
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

docker-compose.yaml.mako:

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

Collision detection

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

files =
    foo_1.sh.mako : foo_1.sh
    foo_2.sh.mako : foo_1.sh  # overwrites ``target`` form above

will result in a build fail with the message:

Target collision is detected at 'foo_2.sh.mako : foo_1.sh'

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

Metadata

Release files for buildout.recipe.mako_template 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for buildout.recipe.mako_template 0.1.2
File Size Uploaded
buildout.recipe.mako_template-0.1.2.tar.gz 11.5 kB Details

Release files / buildout.recipe.mako_template-0.1.2.tar.gz

Download URL buildout.recipe.mako_template-0.1.2.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
67b5abb0e055f7a049cb1995d3223d95d73a02ec9cce1110e757d5bcb5635373
BLAKE2b-256 checksum
How to use checksums
9401a5c90464ebecfeff8484e7f70894da558f57259bfae1f7c47dd89bcdd9b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page