Giter Club home page Giter Club logo

amplecode.recipe.template's Introduction

amplecode.recipe.template

amplecode.recipe.template is a Buildout recipe for generating files using Jinja2 templates. The recipe configures a Jinja2 environment, by default relative to the Buildout directory, allowing templates to extend and include other templates relative to the environment.

Downloads are available from pypi: http://pypi.python.org/pypi/amplecode.recipe.template/

Buildout Options

  • template-file (required): One or more Jinja2 template file paths.
  • target-file (required): One of more target file paths. The number of files must match the number of template files.
  • base-dir: Base directory of the Jinja2 environment. Template file paths are relative to this directory. Default is the Buildout directory.
  • target-executable: One or more boolean flags (yes|no|true|false|1|0) indicating the executability of the target files. If only one flag is given it is applied to all target files.
  • eggs: Reserved for a list of eggs, conveniently converted into a pkg_resources.WorkingSet when specified.

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

Lists of Values

It is possible for a recipe option to contain one or more values, separated by whitespace. A split filter is available for when you want to iterate over the whitespace separated values in your Jinja2 template:

#!/bin/sh
{% for cmd in cmds|split %}
   echo "{{ cmd }}"
{% endfor %}

Minimal Example

foo.txt is created from foo.txt.jinja2 without any extra options:

[buildout]
parts = foo

[foo]
recipe = amplecode.recipe.template
template-file = foo.txt.jinja2
target-file = foo.txt

Larger Example

foo.txt is created from myapp/foo.txt.jinja2, bar.sh is created from myapp/bar.sh.jinja2, the second will be executable, and both templates can utilize the additional options specified:

[buildout]
parts = foo

[foo]
recipe = amplecode.recipe.template
base-dir = myapp
template-file =
    foo.txt.jinja2
    bar.sh.jinja2
target-file =
    foo.txt
    bar.sh
target-executable =
    false
    true
project_name = Another Example
author = Me

Changelog

See the CHANGELOG file

License

See the LICENSE file

amplecode.recipe.template's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

amplecode.recipe.template's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.