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
1
vote
0 answers

JQuery plugin function not found on a Cheetah Template

I am trying to make a comment form for a website that allows users to leave their name, email, and a comment on an html file that is a cheetah template. I want to use this JQuery plugin to validate input: http://docs.jquery.com/Plugins/validation I…
mjb81
  • 11
  • 1
1
vote
4 answers

Cheetah template engine calling python base function

I am using Cheetah template together with Cherrypy, below is my main python file Main.py: def multiple(a,b): return a*b def index(self): t = Template('template.tmpl') #blah implementation here In my template file, I wish to…
drhanlau
  • 2,517
  • 2
  • 24
  • 42
1
vote
1 answer

Facing syntax error while running source venv.source on mac terminal

I am running "source venv.source" command in my Mac terminal inside a cloned repo from Github, can someone please help me. ========================================= Activating virtual environment ========================================= Executing:…
1
vote
1 answer

How to catch Cheetah NameMapper.NotFound exception?

I've a piece of code: #try: $inv.customer.org.name #except NameMapper.NotFound #try: …
Juha Tuomala
  • 111
  • 11
1
vote
1 answer

How do I use inheritance in Cheetah templates?

For Cheetah3, there is a very rough documentation of the inheritance feature: http://cheetahtemplate.org/users_guide/inheritanceEtc.html#extends But I don't get how to make it actually work. Let's assume I have two template files: A.tmpl #def…
nasezoll
  • 101
  • 1
  • 5
1
vote
1 answer

How to render unicode characters in a Cheetah template?

I would like to render a variable with Unicode characters, using the Cheetah template engine. My template file template.txt looks like this: This is static text in the template: äöü This is filled by Cheetah: $variable My program loads that file,…
Nijin22
  • 850
  • 13
  • 20
1
vote
1 answer

How can you add thousand separator when formatting a number in Cheetah?

I'm trying to format a number as a price in Cheetah3 (Python 3.6). While I have succeeded to limit to 2 decimals using the standard formatting expression, the comma separator doesn't seem to work (I get an error). Cheetah Expression: #def…
Geeho
  • 210
  • 2
  • 10
1
vote
1 answer

variable nested templates in cheetah

i have a base template that calls a nested template based on a variable passed in, eg. page = 6 and what i want is to call some html as follows: ...
#include "templates/_page${page}.tmpl"
... what is the correct syntax for this?…
khany
  • 1,167
  • 15
  • 33
1
vote
1 answer

Static attributes in Cheetah

I'm working on a project using Cheetah. I'd like to create a class like the following one: from Cheetah.Template import Template class TemplateObject(Template): className = "Default ClassName" def header(self): return "My Class name…
Xatyrian
  • 1,364
  • 8
  • 26
1
vote
1 answer

syntax error with '$' sign ; Cheetah / bash

I work on a script running Cheetah ; at some point there are some bash commands and I got a syntax error ("Error in the Python code which Cheetah generated for this template"). The line involved is : && name=$(echo '\$another_variable'".phy" | cut…
Micawber
  • 707
  • 1
  • 5
  • 19
1
vote
1 answer

Append to existing dictionary in Cheetah-based template

I'm trying to add my own custom lines into the Cobbler snippet as Cheetah code. I can create a dictionary using #set, but how do I append to the same dictionary down the line? ... #set…
Riz Lee
  • 13
  • 2
1
vote
0 answers

Cheetah requires Python module Cheetah 2.1.0 or newer - laucnhing sickbeard

I am trying to use sickbeard on a mac via terminal. I have installed the latest version pf python (homebrew), then installed cheetah (git then python setup.py install). when finally i try to: python sickbeard.py I get this message: Sorry, requires…
Freddy
  • 15
  • 9
1
vote
1 answer

Python cheetah variables inside a #raw javascript block?

If I have a block of #raw that has javascript inside it and sometimes I need to access some python variables (the $foo in example case) from that javascript. #raw