Is there an existing good example, or how should one approach creating a basic Template system (thinking MVC) that supports "Template Inheritance" in PHP5?
For an example of what I define as Template Inheritance, refer to the Django (a Python framework for web development) Templates documentation: http://docs.djangoproject.com/en/dev/topics/templates/#id1
I especially like the idea of PHP itself being the "template language", though it's not necessarily a requirement.
If listing existing solutions that implement "Template Inheritance", please try to form answers as individual systems, for the benefit of 'popular vote'.
To use Template Inheritance we must first create a base template. A base template is just a simple skeleton that we will be used as a base for all other pages on our site. A base template defines areas where content can be inserted into. In Django, we define this area using the block tag.
extends tag is used for inheritance of templates in django. One needs to repeat the same code again and again. Using extends we can inherit templates as well as variables.
Django Template Language or DTL is a text-based Template language that provides a bridge between scripts like HTML, CSS, JS, etc. and programming languages like python. DTL is specifically built for developers to embed Django logic codes into HTML template files.
Ad. Ad. A PHP template engine is a concise syntax used by front-end developers to display data prepared by back-end developers.
Sorry to dig up an old thread, but I just released a library that does template inheritance in native PHP. Very inspired by Django. Please check it out and let me know what you think:
"PHP Template Inheritance"
http://arshaw.com/phpti/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With