ClearSilver

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(Success Stories)
第82行: 第82行:
 
*[http://www.bloglines.com/ Bloglines] - Used by the server based RSS aggregator. (C)
 
*[http://www.bloglines.com/ Bloglines] - Used by the server based RSS aggregator. (C)
 
*[[Hassan Image Server]] - a server for sharing web-browsable photo repositories. (Python)
 
*[[Hassan Image Server]] - a server for sharing web-browsable photo repositories. (Python)
 +
 +
[[Category:Template]]

2010年8月22日 (日) 01:12的版本

ClearSilver is a fast, powerful, and language-neutral template system. It is designed to make it easy to create template driven static or dynamic websites.

http://www.clearsilver.net/

ClearSilver is first and foremost designed to be extremely fast. It is coded completely in C and exported to your script language of choice (i.e. Python, Perl). As a result, it is notably faster than template systems written in a script language. However, its design has additional benefits. It is also one of the only template systems available which allows you to easily mix-and-match multiple programming languages with the same templates, even on the same page. This allows you to optimize your website by writing C-modules to handle speed-sensitive sections, while leaving the majority of your site in easy to write script code.

Brandon Long. http://www.fiction.net/blong/

目录

Features

  • Fast, simple, language-neutral template system.
  • Modules currently available for C, Python, Perl.
  • Powerful template language supports variable substitution, template includes, conditionals, loops, macros, recursive macros, local variables.
  • Full CGI-handling kit with support for CGI/1.1, RFC 2388, automatic gzip compression, and other CGI standards.
  • "Pipelined" rendering model stores rendering data in an intermediate static dataset and makes debugging easier.
  • Separate your web application from its appearance.
  • Allow non-programmers access to edit parts of the site appearance.
  • Open Source and non-restrictive license

ClearSilver由3各部分组成:hdf数据描述,cst模版文件,py逻辑处理向hdf赋值

Clearsilver-Architecture.gif

Install

Debian

#apt-get install clearsilver-dev - headers and static library for clearsilver
#apt-get install python2.3-clearsilver - python bindings for clearsilver

or

./configure --prefix=/opt/clearsilver-0.10.2 \
 --with-python=/opt/python-2.4.2/bin/python \
 --disable-ruby --disable-java --disable-perl --disable-apache --disable-csharp

or windows

http://clearsilver.yi.org/

Example

编写hdf文件:hello.hdf

# This is my static data for Hello World (and this is a comment)
Hello = Hello World!
WeekDays {
        0 = Sunday
        1 = Monday
        2 = Tuesday
        3 = Wednesday
        4 = Thursday
        5 = Friday
        6 = Saturday
}

编写模版文件:hello.cst

<?cs var:Hello ?>

<?cs each:day = WeekDays ?> On <?cs var:day ?>, <?cs var:Hello ?>
<?cs /each ?> <?cs if:?Query.day ?> On <?cs var:WeekDays[Query.day] ?>, <?cs var:Hello ?>
<?cs /if ?> Hey <?cs var:html_escape(Query.name) ?>, <?cs var:Hello ?>

这个模版文件唯一要注意的就是cs if:?Query.day,是用来处理链接参数的:cgi-bin/hello.py?day=1

然后将这两部分合二为一:

#!/usr/bin/python
#
# Hello World using the ClearSilver CGI Kit and Python

import neo_cgi

# create a CGI handler context
ncgi = neo_cgi.CGI()
 
# parse the form data (and post upload data)
ncgi.parse()
 
# Load our static data
ncgi.hdf.readFile("hello.hdf")

ncgi.display("hello.cst")

example from http://wiki.woodpecker.org.cn/moin/ClearSilver

http://www.clearsilver.net/docs/python/examples.cst

Success Stories

  • Google Groups 2 - The new version of Google Groups uses ClearSilver. (C++/Python)
  • Yahoo Groups! is authored in ClearSilver's ancestor, "CS/HDF". (C, Python)
  • For HTML rendering, Trac uses the ClearSilver templating system.
  • Discogs - Discogs is a user-built database containing information on artists, labels, and their recordings. (Python)
  • Bloglines - Used by the server based RSS aggregator. (C)
  • Hassan Image Server - a server for sharing web-browsable photo repositories. (Python)
分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱