Template Language for a CMS

How would you go about creating a template language that could be used to allow access to *some* helpers for a CMS-style app?

For example if there is a text field called content, I can use Textile or (my preference) Markdown to allow easy html generation, but they don't allow for any conditional markup based on the page. Is there any way to extend these languages by allowing access to some of the helper methods.

I was thinking something like:

% image(bart.png) %

% breadcrumbs %

% nav_menu(child_pages) %

Does something like this exist? Would it be better to try to extend markdown or write one from scratch? How would you go about writing one?

cheers,

DAZ

Thanks Macario,

Liquid looks like what I'm after - and the railscast (as always) is excellent. It seems like I could hook some specific helper methods up to it and they could be outputted using {{ this notation }}

Out of interest ... how does one go about writing their own template language? Any basic way of starting?

cheers,

DAZ