txTemplate

ภาพหน้าจอของซอฟแวร์:
txTemplate
รายละเอียดซอฟแวร์:
รุ่น: 1.0.2
วันที่อัพโหลด: 20 Feb 15
ผู้พัฒนา: Mike Steder
การอนุญาต: ฟรี
ความนิยม: 5

Rating: nan/5 (Total Votes: 0)

txTemplate เป็นโมดูลหลามที่ให้อะแดปเตอร์สำหรับไม่กี่เครื่องมือแม่แบบที่เป็นที่นิยมจะทำให้พวกเขาได้อย่างง่ายดาย callable และใช้งานได้ภายในบิดเว็บ
txTemplate ใช้ zope.interface เพื่อให้โหลดที่สอดคล้องกันและอินเตอร์เฟซแม่แบบสำหรับเครื่องยนต์ทุกแม่แบบ
สนับสนุนเครื่องยนต์แม่แบบ
- ClearSilver
- Genshi
- Jinja2
เริ่มต้น
จริงๆสิ่งที่คุณต้องทำเพื่อใช้ใน txTemplate บิดคือ
- นำเข้า
- สร้างรถตักชี้ไปที่ไดเรกทอรีแม่แบบของคุณ
- โหลดแม่แบบที่มีการตักกล่าวว่า
- template.render โทรแนบเรียกกลับจะกลายเป็นรอการตัดบัญชี (ถ้าต้องการ) และกลับจากรอการตัดบัญชีและ render_ twisted.web.resource.Resource คุณ * วิธีการ
นี่คือตัวอย่างของรหัสของทรัพยากรเว็บบิดที่ใช้ txTemplate ที่จะทำให้แม่แบบที่น่ารัก Genshi จะพูด Hello World ใน HTML:
นำเข้าระบบปฏิบัติการ
นำเข้าจากอินเทอร์เน็ต twisted.application
จากการนำเข้า twisted.internet เครื่องปฏิกรณ์
จากแหล่งนำเข้า twisted.web
นำเข้าจากเซิร์ฟเวอร์ twisted.web
นำเข้า txtemplate
TEMPLATE_DIR = os.path.join (os.path.dirname (os.path.abspath (__ file__))
& nbsp; "แม่แบบ")
คลาส HelloWorld (resource.Resource):
& nbsp; def __init __ (ตัวเอง):
& nbsp; resource.Resource .__ init __ (ตัวเอง)
& nbsp; self.loader = txtemplate.GenshiTemplateLoader (TEMPLATE_DIR)
& nbsp; def getChild (ตัวเองชื่อคำขอ):
& nbsp; กลับตัวเอง
& nbsp; def render_GET (ตัวเอง, ขอ):
& nbsp; template_name = "hello.xhtml"
& nbsp; แม่แบบ = self.loader.load (template_name)
& nbsp; context = {"อวยพร": "สวัสดี"
& nbsp; "greetee": "โลก"}
& nbsp; def CB (เนื้อหา):
& nbsp; request.write (เนื้อหา)
& nbsp; request.setResponseCode (200)
& nbsp; request.finish ()
& nbsp; D = template.render (** บริบท)
& nbsp; d.addCallback (CB)
& nbsp; กลับ 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

ความคิดเห็นที่ไม่พบ
เพิ่มความคิดเห็น
เปิดภาพ!