Git Product home page Git Product logo

collective.recipe.template's Introduction

Introduction

This recipe can be used to generate textfiles from a (text) template.

A short example:

[buildout]
parts = message

[message]
recipe = collective.recipe.template
input = templates/message.in
output = ${buildout:parts-directory}/etc/message

mymessage = Hello, World!

In the template you can use the exact same variables as you can use in the buildout configuration. For example an input file can look like this:

My top level directory is ${buildout:directory}
Executables are stored in ${buildout:bin-directory}

As an extension to the buildout syntax you can reference variables from the current buildout part directly. For example:

My message is: ${mymessage}
  • Starting with version 1.3, you can also specify a path to the output file and the path will be created if it does not exist.
  • Starting with version 1.5, you can use inline templates.
  • Starting with version 1.7, you can use genshi text templates.
  • Starting with version 1.9, you can use a URL to specify template input.
  • Starting with version 1.12, you can specify timeout as an option to configure urllib2 requests.

A short example:

[buildout]
parts = message

[message]
recipe = collective.recipe.template[genshi]:genshi
input = templates/message.in
output = ${buildout:parts-directory}/etc/message
some-option = value

mymessage = Hello, World!

In the template you can use the exact same variables as you can use in the buildout configuration, but instead of colons as the separator you either have to use attribute access, or for options with a dash dictionary syntax. The global buildout config is accessible through parts, the current part through options.

For example an input file can look like this:

My top level directory is ${parts.buildout.directory}
Executables are stored in ${parts.buildout['bin-directory']}
Accessing the current part: ${options['some-option']}

Both iw.recipe.template and inquant.recipe.textfile claim to do the same thing. I have found them to be undocumented and too buggy for real world use, and neither are in a public repository where I could fix them. In addition this implementation leverages the buildout variable substitution code, making it a lot simpler.

collective.recipe.template's People

Contributors

alecghica avatar baijum avatar cedricmessiant avatar davidjb avatar fschulze avatar gforcada avatar hvelarde avatar lukasgraf avatar mitchellrj avatar mstaniszczak avatar regebro avatar

Watchers

 avatar  avatar

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.