开发者

How To Build a Template Engine

开发者 https://www.devze.com 2023-01-23 15:43 出处:网络
I\'ll be building this in Google App Engine and I\'ll be Building it using Python. What I\'d like to do is have a template that holds each section.With the sections probably being header, sidebar, co

I'll be building this in Google App Engine and I'll be Building it using Python.

What I'd like to do is have a template that holds each section. With the sections probably being header, sidebar, content and footer.

The way I would build it is so that I can call page.header(arg) and it will load the header that the arg specifies开发者_如何学Python.

I know there are a lot of frameworks, but I want to try and build a website based on the MVC idea my self. I figure it will probably take 6 months or more to build, but at least I'll learn something along the way.

What else do I need to think about building a template engine?


I would check out Webpy sources;
webpy templating uses a syntax similar to yours, calling the views with something like:

name = 'Bob'    
return render.index(name)

where index is the templating file to render.

Have a look to templating.py specifically.

0

精彩评论

暂无评论...
验证码 换一张
取 消