[stringtemplate-interest] Multimethods

Roman Odaisky roma at qwertty.com
Mon Nov 10 22:46:23 PST 2008


On Monday, 10.11.2008 19:34:33 Terence Parr wrote:

> Is there a string you can pass to a renderer that can be broken apart
> to compute the proper URL? If the URL is truly computation, then it
> must be a part of the controller; the controller does the mapping of
> URL to executable code. This is case, then it would violate MVC
> separation to compute URLs in the view.

I need a way to say, “Here I need a link to a page that would refer to X and 
Y”. Something like <a href="$blog_posts(y=2008, m=2, d=8)$"> that would 
result in .../2008/02/08/... or .../2008-02-08/... or something else 
depending on configuration.

To me this looks very declarative and not violating anything.

A hackish alternative would be to overload the [] operator of a class:
$URL.(y).(m).(d)$.

I could also precompute the URLs and pass them along the actual objects, but 
the amount of URLs required seems to grow too fast.

What’s wrong with the first solution?

-- 
TIA
Roman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2286 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20081111/cc04df53/attachment.bin 


More information about the stringtemplate-interest mailing list