Tesugen

Burps

I’ve been thinking a lot about Burger recently. I’ve not been working on it at all, though. Anyway, I’m not happy about the templates. They are too simple. I would want to be able to do more sophisticated things. And I’ve been toying with the idea to make templates work a little like JSP pages. I call this “burps” – burger pages.

As an example, consider the following burp:

&lt;% @initialize criterion = "CountCriterion.new(10)" %&gt; <br /> &lt;HTML&gt; <br /> ... <br /> &lt;% page.entries.each do |entry| %&gt; <br /> &lt;H2&gt;&lt;%= entry.title %&gt;&lt;/H2&gt; <br /> &lt;DIV CLASS="blogbody"&gt; <br /> &lt;%= entry.body %&gt; <br /> &lt;/DIV&gt; <br /> &lt;% end %&gt; <br /> ... <br /> &lt;/HTML&gt; <br />


This would be read and “compiled” into a PageTemplate object, which would have a CountCriterion initialized to accept 10 blog entries and a write method that looks like this:

def write(writer) <br /> &nbsp;&nbsp;&nbsp;&nbsp;writer.write("&lt;HTML&gt;") <br /> &nbsp;&nbsp;&nbsp;&nbsp;writer.write("...") <br /> &nbsp;&nbsp;&nbsp;&nbsp;page.entries.each do |entry| <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.write("&lt;H2&gt;#{entry.title}&lt;/H2&gt;") <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.write("&lt;DIV CLASS="blogbody"&gt;") <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.write("{#entry.body}") <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.write("&lt;/DIV&gt;") <br /> &nbsp;&nbsp;&nbsp;&nbsp;end <br /> &nbsp;&nbsp;&nbsp;&nbsp;writer.write("...") <br /> &nbsp;&nbsp;&nbsp;&nbsp;writer.write("&lt;/HTML&gt;") <br /> end


This would let you do anything you can do in Ruby on each page of your weblog. I’m thinking of qualifying the criterion with a key, so that you can have different criteria for each page. Say you’ll want five random blog entries in a sidebar, then you would have one CountCriterion for the key “main”, for your regular n latest bloggings, and a RandomCriterion (credit to Malte for the idea) for the key “random”. And in your burp, you would be able to do a page.entries("random").each and enumerate the random entries in your sidebar. Or something like that.

I’m also thinking (again after discussions with Malte) about having something resembling the WOResourceManager in WebObjects, so that you can get relative URL’s in your HTML pages, and absolute URL’s in your RSS feed (for images and such). This could also be used to retrieve static HTML segments, like my book list to the right. Currently, it’s duplicated in the template for my about page (which demonstrates the RandomCriterion, in case you’ve missed it).

The above was posted to my personal weblog on August 24, 2002. My name is Peter Lindberg and I am a thirtysomething software developer and dad living in Stockholm, Sweden. Here, you’ll find posts in English and Swedish about whatever happens to interest me for the moment.

Posted around the same time:

The seven most recent posts:

  1. Tesugen Replaced (October 7)
  2. My Year of MacBook Troubles (May 16)
  3. Tesugen Turns Five (March 21)
  4. Gustaf Nordenskiöld om keramik kontra kläddesign (December 10, 2006)
  5. Se till att ha två buffertar för oförutsedda utgifter (October 30, 2006)
  6. Bra tips för den som vill börja fondspara (October 7, 2006)
  7. Light-Hearted Parenting Tips (September 16, 2006)
Bloggtoppen.se