1.1 Markup and Code

As we well know, html is a markup language, not a programming language. If we wish to create dynamic web pages, a programming language has to be combined with the html in some way.

One of the reasons for creating Draco is that I felt that in existing systems this combination often led too poor separation of markup (the html) and code (the program logic). Good separation of code and markup is beneficial in several ways:

At the same time I realize that it is impossible to have a total separation of code and markup. However, I think this separation should be maximized and in Draco I have tried to do this. In Draco, code and markup are split up into handlers and templates. A handler is a function that performs the operations that were requested by the client via the web. The output of the handler is a set of named variables that is stored in a namespace called the interface. The template is an html document that contains embedded code blocks, marked by special tags. The only thing this embedded code should do is to format the variables stored in the interface in the desired way. I have found that this separation between functional program code on one side and code that merely formats results on the other side greatly improves the overall markup-code separation. My experience is that almost any dynamic web page is naturally split up in a part that does the work, and a part that formats the results. But, if in special cases this cannot be done, any of the handler or the template can be left empty.