Questions tagged [cheetah]

Cheetah3 is a free and open source (MIT) Python template engine. Works with Python 2.7 and 3.4+.

Where is CheetahTemplate3

Site: https://cheetahtemplate.org/

Download: https://pypi.org/project/CT3/

News and changes: https://cheetahtemplate.org/news.html

Mailing lists: https://sourceforge.net/p/cheetahtemplate/mailman/

Development: https://github.com/CheetahTemplate3

Developer Guide: https://cheetahtemplate.org/dev_guide/

Example

Install:

$ pip install CT3 # (or even "ct3")

Below is a simple example of some Cheetah code, as you can see it's practically Python. You can import, inherit and define methods just like in a regular Python module, since that's what your Cheetah templates are compiled to :) :

#from Cheetah.Template import Template
#extends Template

#set $people = [{'name' : 'Tom', 'mood' : 'Happy'}, {'name' : 'Dick',
                        'mood' : 'Sad'}, {'name' : 'Harry', 'mood' : 'Hairy'}]

<strong>How are you feeling?</strong>
<ul>
    #for $person in $people
        <li>
            $person['name'] is $person['mood']
        </li>
    #end for
</ul>
73 questions
14
votes
2 answers

Python: format string with custom delimiters

EDITED I have to format a string with values from a dictionary but the string already contains curly brackets. E.g.: raw_string = """ DATABASE = { 'name': '{DB_NAME}' } """ But, of course, raw_string.format(my_dictionary) results in…
Don
  • 16,928
  • 12
  • 63
  • 101
7
votes
1 answer

HTML/CSS/JS Syntax Highlighting in Eclipse

Hello How can I enable syntax highlighting for HTML/CSS/JS in Eclipse I am mainly developing in python using the PyDev package but right now I am creating Cheetah templates and they are very hard to read unhighlighted. Any plugin/package suggestions…
BillPull
  • 6,853
  • 15
  • 60
  • 99
5
votes
1 answer

Using Cheetah Templating system with windows and python 2.6.1 (namemapper problem)

So I am trying to use the Cheetah templating engine in conjunction with the Django web framework, and that is actually working fine. I did some simple tests with that and I was able to render pages and whatnot. However, problems arise whenever…
Daniel Waltrip
  • 2,530
  • 4
  • 25
  • 30
4
votes
1 answer

cheetah templating with flask

I can't seem to find any information about using the cheetah templating engine with flask. Can anyone point me to something that google can't find, or show me how to use cheetah templates in a simple flask app?
Hoopes
  • 3,943
  • 4
  • 44
  • 60
4
votes
2 answers

Python shared libraries - Cheetah namemapper.so not found

I'm using Python Cheetah for template generation and I can't get it to use the compiled _namemapper.so library that is installed. I am running on CentOS 5.4 with Python 2.4 installed, using Cheetah 2.4.3. I cannot for the life of me get Cheetah to…
purecharger
  • 1,213
  • 2
  • 15
  • 34
3
votes
1 answer

Automatic compilation of parent templates

I am trying to setup dynamic compilation of Cheetah templates, useful for development (so I don't have to recompile them with cheetah compile after each change). Seems like Cheetah.Template.Template is right API for that, but it simply doesn't…
Roman Bodnarchuk
  • 29,461
  • 12
  • 59
  • 75
3
votes
0 answers

Can I use linting/fixing tools on a Cheetah template?

I’m trying to use prettier to fix Javascript/HTML code formatting. Unfortunately the final Javascript/HTML is generated from a Cheetah template, so there are many lines that start with # characters. Those are throwing errors that prevent Prettier…
user2597451
  • 1,903
  • 2
  • 12
  • 10
3
votes
1 answer

Python Cheetah - Specify name/value pairs for templating

I am trying to template-ize my Apache httpd configuration for deployment to different environments and I would like to use the Python language Cheetah application to do so. However, I am having difficulty with the command line cheetah program and I…
purecharger
  • 1,213
  • 2
  • 15
  • 34
3
votes
2 answers

AppEngine database model has has_key() method but is not iterable?

I am getting: argument of type 'Lantern' is not iterable in one of the template engine files (Cheetah). As you can guess the obj is a Lantern (see below). NameWrapper.py: if hasattr(obj, 'has_key') and key in obj: This is a simplified version of my…
kev
  • 8,928
  • 14
  • 61
  • 103
3
votes
0 answers

Is there something like Qt Designer for the web on Linux?

I'm very used to using Qt Designer to design GUIs, and I would like to be able to use something similar on a Python project I'm working on that I'd like to create a web interface for, but I find that a similar tool seems to be no where to be…
supercheetah
  • 3,200
  • 4
  • 25
  • 38
2
votes
2 answers

Looping through a collection has different behaviour if source has only one item with Python Cheetah3

I'm trying to write some code that will parse a collection/list/array etc and I had this working when the size is greater than 1. However when only 1 item is in the collection the code fails as the behaviour appears to be different. Using the below…
Cynan
  • 160
  • 1
  • 5
2
votes
1 answer

How should I access Cheetah Template() variable placeholders in an object instance?

I'm trying to set up an object instance that will provide values to the Cheetah3 text templating engine. This is my text template script... #filename: py_text_template.py from traits.api import String, Range from traits.api import HasTraits from…
Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
2
votes
1 answer

Problem in installing update cheetah==2.4.4

I'm trying to install updates from my requirements.txt: pip install -r requirements.txt but when the installing has arrived to cheetah it printed this error: I'm trying to run some updates require by pycharm, so for the update of cheetah I got this…
Moez Ben Rebah
  • 170
  • 1
  • 12
2
votes
1 answer

cheetah template importing functions

So I am having some trouble trying to import functions and run them inside my cheetah templates. So I have one file that lives at /docroot/tmpl/base.html and then another file that is /docroot/tmpl/comments.html inside of comments I have something…
BillPull
  • 6,853
  • 15
  • 60
  • 99
2
votes
2 answers

Cheetah #include doesn't place #def within scope

When I include a file using #include (without raw) it parses the content correctly, but the #def which I want to access within the original file doesn't exist & an error is thrown. Base Template: #def sayHello($name) hello $name #end…
smokedice
  • 900
  • 2
  • 10
  • 25
1
2 3 4 5