
2008年6月26日
模板語法
模板語法類似于Velocity
1. 注釋
## single line
#* multi line *#
2. PlaceHolder
PlaceHolder就是用來輸出到界面上的元素
發現了比較厲害的幾個地方
* 可以直接使用python中的內嵌對象, 如range()函數
* 可以引入pythong的library中的東西
* 自定義的變量,函數,類,對象都可以通過searchList傳到模板上使用
也就是說,在模板里面,可以完成任何python能完成的事情。這個是我見過的其它的模板語言沒有的。
posted @
2008-06-26 16:37 JustRun 閱讀(451) |
評論 (0) |
編輯 收藏

2008年6月25日
1. Template對象構造
Template對象有7種構造方法, 分別如下:
- * 直接使用字符串
t = Template("The king is a $placeholder1.")
Pass the template definition as a string.
- * 使用模板文件
t = Template(file="fink.tmpl")
Read the template definition from a file named "fink.tmpl".
- *使用文件對象
t = Template(file=f)
Read the template definition from file-like object 'f'.
- *重載方法,加入填入信息
t = Template("The king is a $placeholder1.", searchList=[dict, obj])
t = Template(file="fink.txt", searchList=[dict, obj])
t = Template(file=f, searchList=[dict, obj])
posted @
2008-06-25 17:45 JustRun 閱讀(333) |
評論 (0) |
編輯 收藏
1. Cheetah命令使用
Cheetah的文檔上有講如何使用Cheetah命令來編譯一個模板,編譯成一個python的module.
但是windows查了一下,沒有這個執行命令
在硬盤上搜了一下,發現原來是個在C:\Program Files\Python25\scripts目錄下有一個文件是Cheetah,但是沒有后綴名,用文本編輯器打開看了一下,就是文檔中提到的命令.
可能它默認的是在linux環境中執行,所以,沒有后綴名只要是可執行文件就可以了.
現在copy一份Cheetah,把后綴名改成Cheetah.py就可以用這個文件編譯模板了
命令
Cheetah c 編譯模板文件
Cheetah f 填充模板文件
posted @
2008-06-25 17:10 JustRun 閱讀(402) |
評論 (0) |
編輯 收藏

2008年6月19日
一, Cheetah介紹和網址
Cheetah的讀音像是cheater, 看來要上當了.
它是一個python的模板引擎.
官方網址: http://www.cheetahtemplate.org/
二, windows下安裝
安裝很容易,按照文檔就可以了,不過好像安裝的時候,沒有安裝到提到的C module, 不過文檔里面講沒有找到的話,會使用python寫的替代, 只是效率會有問題.
OK, 安裝完畢, 運行第一個例子, 通過.
posted @
2008-06-19 22:00 JustRun 閱讀(476) |
評論 (0) |
編輯 收藏

2006年12月19日
?private string _name;
?????????????? public string Name
??????? {
??????????? get
??????????? {
??????????????? return _name;
??????????? }
??????????? set
??????????? {
??????????????? _name=value;
??????????? }
??????? }
posted @
2006-12-19 18:16 JustRun 閱讀(657) |
評論 (0) |
編輯 收藏
現在從事的工作是.NET開發。
本人興趣python, mysql, linux等開源軟件開發和使用
|
|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
常用鏈接
留言簿(1)
隨筆分類
隨筆檔案
搜索
最新評論

閱讀排行榜
評論排行榜