Wilcox Development Solutions Blog

Shifting Gears

July 16, 2007

We know a lot about the JavaScript to/from C++ API in WebKit. We don’t have all the pieces yet (we don’t know how to call C++ from JavaScript, for example, and the code to convert a C++ value into a KJS::JSValue needs to be written), but for the sake of research let’s keep going forward for now.

We have a web control, but we need something to display in it. In our case (constructing HTML mostly from scratch) we really don’t want to code all that HTML into our C++ program: that would make the HTML much harder to change than it should be. Ideally we want to load the HTML from a file, run it through some HTML template system that replaces (markers we left in the HTML code) with values from the C++ program.

Over the weekend I looked into these systems, and I found two: ClearSilver and Google CTemplate. ClearSilver is a C based library, available for multiple languages (including C++ bindings). It looks well used from what I can see. It also looks really complex, and the C++ bindings are very involved.

Google’s CTemplate is much better: a very simple C++ facing API, and still a fairly powerful HTML templating language. It seems that Google is switching from ClearSilver over to this. This says two things to me: that it’s Fast Enough For Google, and There Has To Be A Reason Google Wrote Its Own When It Had ClearSilver. (I suspect the answer is: this is simpler).

So I’m going to take Google’s CTemplate out for a ride: see if we can get a very basic version of our main screen working.