Midnight Beach logo

Ethiopia - Semantics

Moving the sitemap out of the pages saved a lot of time. Similarly, templates with named values let me do things like set a page name in one place, and have it appear in multiple places on the page. If I changed one value on one page, all the references on that page would change properly; if I changed the template, all the pages would change. The next evolutionary step in effect moved simple macros into the template (or page files) and allowed me to do semantic markup in a way that CSS does not.

The template program originally just read everything in a page file that wasn't a named string setting, and called that the Body string. I added a step which looked for 'function calls' like @Name("this", "That")@. If there was a string named Name, I'd pass its value to the .Net String.Format() function as a pattern into which the values "this" and "That" should be inserted. The way this works is that Format() returns the pattern string - with every instance of {0} replaced with the first piece of data ("this", in this example), every instance of {1} replaced with the second piece of data, and so on. That is, the .Net Format() function is much like the printf() functions in C-like programming languages.

This means that I can define simple boilerplate for a site in the site's template, not in a special macro module written in a real programming language. This in turn makes it easy to do semantic markup of various parts of the text, and freely change the visual appearance of each design element; there's no danger of changing This bit of boilerplate that only happens to look like That semantic type of design element. For example, if I define localLink and remoteLink macros, I can include all the <a> tag boilerplate in the macro: Now I can make a remote link open a new browser window while a local link just loads the new page in the current browser window. If I want to change the way either acts (or looks) I just have to change the macro definition in the template file, and every local or remote link in the page group changes automatically.

This simple sort of macro substitution was almost powerful enough for me to totally revamp a 140 page site, but eventually the hardwired menu function came to be joined by two others.


Created on May 10, 2003, last updated May 12, 2003 • Contact jon@midnightbeach.com