How to create a template engine

I will build it in the Google App Engine, and I will build it using Python.

What I would like to do is have a template that contains each section. With sections that are probably the header, sidebar, content, and footer.

The way I built it is so that I can call page.header (arg) and it will load the header that arg indicates.

I know that there are many frameworks, but I want to try to create a site based on the idea of ​​MVC. I believe it will probably take 6 months or more to build, but at least I will learn something along the way.

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

+3
source share
1 answer

I would look at Webpy sources.
webpy templating uses a syntax similar to yours that calls views with something like:

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

where indexis the template file for rendering.

Take a look at templating.py in particular.

+2
source

Source: https://habr.com/ru/post/1772961/


All Articles