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
1 answer

Execute stored procedure when a button is clicked on python web

I am creating a webpage that displays a list of object that exist in a database/table. I have a stored procedure which retrieves the data from the table and associates with each column the data will be parse into a table.
Benedict Lee
  • 59
  • 1
  • 9
1
vote
3 answers

How do I truncate floats to two decimal places in cheetah templates?

I'm currently using Cheetah Templates with my python code and I'm passing in a number of floating point numbers. I'd like to truncate these floats to only two decimal places within the template, e.g. 0.2153406 would become 0.21 Is it possible to do…
Andrew Thompson
  • 2,396
  • 1
  • 21
  • 23
1
vote
1 answer

CherryPy with Cheetah as plugin + tool - blank pages

CherryPy keeps returning blank pages or with the values I return in the controllers. I rewrote a django and jinja2 version that did work, apparently this one doesn't which is almost identical to the previous mentioned. I did some pprint's in the…
PvdL
  • 1,578
  • 1
  • 20
  • 33
1
vote
2 answers

Getting python Cheetah to print backslash

I am having trouble getting the Python Cheetah to print a backslash for me. Cheetah version 2.4.4 from Cheetah.Template import Template my_template = """ Stuff $var1\\$var2 """ t = Template(source=my_template, searchList = [{"var1" :…
Kannan Ekanath
  • 16,759
  • 22
  • 75
  • 101
1
vote
2 answers

generating javascript string in python

i have string stored in python variables, and i am outputting a html that contains javascript, and the i need to create javascript variables. for ex, in python title = "What's your name?" i use Cheetah to generate the html. Cheetah code: var title…
kevin
  • 4,177
  • 10
  • 32
  • 33
1
vote
1 answer

Cheetah installing error

I'm trying to install on my machine gnuradio and to do so I have to install another programs, according to this site. Everything goes well but when I have to install the cheetah dependency it gives me this error: c:\Python27\Scripts>easy_install…
1
vote
1 answer

installing cheetah in home directory

I am trying to install the Cheetah template engine in my home directory. I have a school website account and do not have root access. I changed my python path to the directory I am installing to, but it tries to put cheetah-compile in /usr/bin which…
Peter
  • 1,032
  • 1
  • 11
  • 26
1
vote
1 answer

How to substitue better in Cheetah templates

Given the following Cheetah template #filter None {data:[ #for $person in $persons {naam: "#if $person.lastname==None then '' else $person.lastname.replace('"', '\\"')#}, #end for ]} #end filter That's quite a mouthful for replacing " with…
Paul
  • 1,068
  • 11
  • 29
1
vote
1 answer

In emacs how do I add a second type of commenting to a css derived mode?

I have a templating css file type that allows comments to start with '##' No matter what I try though It doesn't seem to recognize this in my derived-mode. Here is what i have so far (define-derived-mode cheetah-css-mode css-mode "cheetah-css" …
telaviv
  • 406
  • 1
  • 7
  • 14
0
votes
1 answer

Using Cheetah Templating Engine with Tornado Web Framework

Has anyone used the Cheetah Templating Engine with the Tornado Web Framework before? Do they work well together and are you able to use Cheetah's caching components within the Tornado Framework? I've been looking for a good, python only solution for…
Drahkar
  • 1,694
  • 13
  • 17
0
votes
0 answers

How to configure Cheetah on Django

Is there a tutorial on how to configure Django and cheetah to print out simple text like hello world in variables or lists? I'm trying to configure cheetah with Django or find instructions on how to or tutorials but without luck. I've already tried…
0
votes
1 answer

How do I set Cheetah 'useAutocalling' off?

I have tryed multiple ways to try and turn this off including #compiler-settings useAutocalling=False #end compiler-settings #compiler-settings useAutocalling=0 #end compiler-settings but I cannot get cheetah to turn it off. The reason I need to…
David Stocking
  • 1,200
  • 15
  • 26
0
votes
1 answer

cheetah parsing error trying to change cheetahVarStartToken

I am writing a cheetah template and I want to change the cheetahVarStartToken so that I can use the $ for javascript libraries in that section of code however when I run the template I am getting this error ConfigParser.ParsingError: File contains…
BillPull
  • 6,853
  • 15
  • 60
  • 99
0
votes
1 answer

How to multiply two parameters in a gnuradio-companion xml file

I have to user set parameters in the grc gui and I need to multiply them to set the output vector length of my block. I cannot figure out how to do this in the grc xml file. I have tried looking at cheetah documentation but it has no examples of…
0
votes
1 answer

Assign a bash command result in a Cheetah variable

I'm currently trying to put the result of a bash command into a Cheetah variable : #set $name = #echo '$input.element_identifier' + ".phy" | cut -d _ -f 1 '$input.element_identifier' Being (sort of) a link to the name of a previous input file (I…
Micawber
  • 707
  • 1
  • 5
  • 19