5/14/2008

Template on PUT

I just had a cool idea. Usually, people run HTML templating engines on GET. They fetch some data, load an HTML template, and then mash the two together. My idea is to instead run the templating engine on PUT. The body of the PUT would have the data to be templated. The URL that was PUT to would determine which template to use. The response from the PUT would contain the fully templated output, equivalent to what the client would get by doing a GET to that url at any point afterwards.


2 comments:

drewp said...

Got a use case, for this "template server"? I'm not seeing it yet. I'm picturing a blog site, where I push entries and then you see them rendered nicely, but that's not a good case for the template rendering happening at PUT time. The usual POST/GET seems to be working fine.

Donovan Preston said...

Yeah, you're right, it's very similar to the current POST to a blog. The difference I guess is that with the PUT you specify which url the resource is going to end up having.
I think one of the keys is that the "shape" of the body would determine which template to use. I'm going to SHDH today, maybe I'll try to come up with a proof-of-concept and see if it's interesting or not.