txTemplate

軟件截圖:
txTemplate
軟件詳細信息:
版本: 1.0.2
上傳日期: 20 Feb 15
開發: Mike Steder
許可: 免費
人氣: 5

Rating: nan/5 (Total Votes: 0)

txTemplate是一個Python模塊,它提供的適配器的幾個​​流行的模板引擎,使他們很容易地調用和使用雙絞線網絡內。
txTemplate使用zope.interface提供一致的加載程序和接口模板為每個模板引擎。
支持的模板引擎
- ClearSilver
- 元史
- 的Jinja2
入門
你真正需要做的,使用txTemplate在扭曲的是:
- 導入
- 創建指著你的模板目錄裝載機
- 加載與所述裝載模板
- 電話template.render,附加回調渲染延遲(如果需要),並返回從twisted.web.resource.Resource render_ *方法和推遲。
下面是一個使用txTemplate呈現一個可愛元史模板說的Hello World在HTML中的扭曲Web資源的代碼示例:
進口OS
從twisted.application進口互聯網
從twisted.internet進口反應堆
從twisted.web進口來源
從twisted.web導入服務器
進口txtemplate
template_dir模板= os.path.join(os.path.dirname(os.path.abspath則(__ FILE__)),
 “模板”)
一流的HelloWorld(resource.Resource):
 高清__init __(個體經營):
  resource.Resource .__的init __(個體經營)
  self.loader = txtemplate.GenshiTemplateLoader(template_dir模板)
 高清getChild(個體經營,名稱,要求):
 回歸自我
 高清render_GET(個體經營,要求):
  TEMPLATE_NAME =“hello.xhtml”
 模板= self.loader.load(TEMPLATE_NAME)
 環境= {“問候語”:“你好”,
 “greetee”:“世界”}
  DEF CB(內容):
  request.write(內容)
  request.setResponseCode(200)
  request.finish()
  D = template.render(**上下文)
  d.addCallback(CB)
 返回server.NOT_DONE_YET
網站= server.Site(的HelloWorld())
reactor.listenTCP(8888點)
reactor.run()
這個例子包括在txtemplate /例子/ txweb.py和root.xhtml模板在txtemplate/examples/templates/root.xhtml.

Requirements:

  • Python

顯影劑的其他軟件 Mike Steder

Goose
Goose

14 Apr 15

意見 txTemplate

評論沒有發現
添加評論
打開圖片!