ANN: CherryTemplate-1.0.0 released

Discussion in 'Python' started by Remi Delon, Nov 18, 2004.

  1. Remi Delon

    Remi Delon Guest

    Hello everyone,

    I'm happy to announce the first release of CherryTemplate, an easy and
    powerful templating system in python.

    Note that it is not "yet another templating system" because it used to
    be part of CherryPy, but is now released as a standalone package.

    Basically, you use it like this:

    $ python
    Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)]
    on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from cherrytemplate import renderTemplate
    >>> name = "world"
    >>> renderTemplate('Hello, <py-eval="name"/>')

    'Hello, world'

    The language only has a few tags: py-eval, py-exec, py-code, py-if,
    py-for, py-include but it is quite powerful because most of python's
    power is still available from the template:
    - "py-for" allows you to do things like <py-for="i,j in [(0,0),
    (1,2), (3,1)]">
    - "py-code" allows you to insert full blocks of pure python code
    inside your template (it takes care of the indentation for you)

    CherryTemplate can also render external templates (ex:
    renderTemplate(file = 'template.html')) and has full unicode support.

    Once nice feature about it is that is uses generators to render your
    template, so if you need to process a large amount of data you can
    tell it to return a generator, and then you can loop through it. This
    way it doesn't use up too much memory. Here is an example:

    >>> template = '''<py-for="i in

    range(5)">i:<py-eval="str(i)"/></py-for>'''
    >>> result = renderTemplate(template, returnGenerator = True)
    >>> for res in result: print repr(res)

    'i:'
    '0'
    'i:'
    '1'
    'i:'
    '2'
    'i:'
    '3'
    'i:'
    '4'
    >>>


    You can find more information (including the download link) on this
    page: http://trac.cherrypy.org/cgi-bin/trac.cgi/wiki/CherryTemplate

    Remi.
     
    Remi Delon, Nov 18, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Hawkins

    [ANN] Confluence 0.7.1 Released

    Tom Hawkins, Oct 23, 2003, in forum: VHDL
    Replies:
    0
    Views:
    500
    Tom Hawkins
    Oct 23, 2003
  2. Tom Hawkins

    [ANN] InFormal 0.1.1 Released

    Tom Hawkins, Nov 9, 2004, in forum: VHDL
    Replies:
    2
    Views:
    491
    Tom Hawkins
    Nov 9, 2004
  3. Jussi Jumppanen

    ANN: Zeus Version 3.95 Editor Released

    Jussi Jumppanen, Aug 8, 2005, in forum: VHDL
    Replies:
    0
    Views:
    438
    Jussi Jumppanen
    Aug 8, 2005
  4. Al Ponomarev
    Replies:
    3
    Views:
    468
    Ken Cox [Microsoft MVP]
    May 3, 2004
  5. Lei Yang
    Replies:
    0
    Views:
    341
    Lei Yang
    Oct 8, 2005
Loading...

Share This Page