21👍
First and foremost, the correct tags for the Django template language are {% %}
, and not <? ?>
.
And you’re correct that this is a part of Django. This is an example of a domain specific language, which, as the Wikipedia says, is a language invented for a particular task. In this case, the Django templating language is built to handle, well, templates.
It works because Django comes with a parser to interpret the language and make sense of it. A parser takes a string that might otherwise has no meaning in HTML or any other language, such as {% block pasta %} and converts it into something meaningful. In this case it ultimately outputs HTML.
It happens that you could write your own parser in any language to interpret the Django templating language, or even write a new language entirely. But the difficulty of such a task increases as your language gets more complex, and also hinges on the language you choose. PHP is notoriously bad at parsing, while other languages like Perl are known to be better at it. In general it’s much easier to just run a search and use a pre-built parser instead of re-inventing the wheel. Though that of course is a lot less fun way to go about it 🙂