GithubHelp home page GithubHelp logo

jhb / chameleon_fetcher Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

A small wrapper for chameleon (page templates) to easily fetch and render templates.

License: GNU General Public License v3.0

Python 100.00%

chameleon_fetcher's Introduction

Chameleon fetcher

A small wrapper for chameleon page templates to easily fetch and render templates.

Installation

pip install chameleon_fetcher

Usage

E.g. you have in template dir my_template_dir a file simple.pt with the following content:

<test>${template_name} ${myvar} ${some_var}</test>

You can then do:

from chameleon_fetcher import ChameleonFetcher

cf = ChameleonFetcher('my_template_dir', some_var=42)
output = cf('simple', myvar='test')
assert output == '<test>simple test 42</test>'

Please note how some_var is set "globally", while for the specific template also a variable myvar is used.

The following parameters are accepted by ChameleonFetcher:

  • template_dir: the directory where the templates are located

And optionally:

  • extension: extension of the template files, defaults to '.pt'
  • boolean_attributes: what boolean attributes should be supported, defaults to all valid html boolean attributes. See https://meiert.com/en/blog/boolean-attributes-of-html/
  • auto_reload: if the templates should be reloaded on change, defaults to True
  • **kwargs: other params you want to have available in all templates, e.g. flask=flask

For using the actual templates, check the fantastic chameleon documentation.

chameleon_fetcher's People

Contributors

jhb avatar

Watchers

 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.