
1 answer(s)
5 answer(s)
I mean for god's sake! On one hand we have people who're trying to teach computers natural language processing, and artificial intelligence; and on the other hand computers can't figure out if was one answer or five answers.
Then I thought, how easy it would be to implement this in ERb:
<%= post.answer_count %> <%= post.answer_count==1 ? "answer" : "answers" %>And then I got thinking how damn painful it would be to implement this in Lisp and HTML-Template. You'd first have to create a flag for each post indicating whether it had a single or multiple answer. Then you'd have to pass all those flags (or list of flags) down to the template filler function. Then you'd have to put a big TMPL_IF statement in the template to achieve the same thing:
<!-- TMPL_VAR answer-count --> <!-- TMPL_IF single-answer -->answer<!-- TMPL_ELSE -->answers<!-- /TMPL_IF -->You could of course, for each post, simply compose the exact string to be displayed ("1 answer", "5 answers") and pass that down to the template. But what's the point of having templates if you can't separate view logic cleanly.
Lisp is a great language, which will probably help you achieve a lot of intellectual orgasms (Meta-object protocol, macros, reader macros, etc.) But it sure does need a good templating tool. I tried hacking around in CL-EMB, but it doesn't really cut it.
[End rant]
fgfff
ReplyDeleteThis comment is not for arument.
ReplyDeleteIf we really think , here
<%= post.answer_count %> <%= post.answer_count==1 ? "answer" : "answers" %>
answer is part logic and not part of view.
Allegro has something called clp
in which above can be written as
< clp_value name="answer-count" session /> answer
< clp_ifgt name="answer-count" value="1" session > s </clp_ifgt >
But clp has other limitations.
Thanks
Nanda programming ko leke bahut senti hai .... :)
ReplyDeleteFor multilingual you have to maintain an extra resource key.
ReplyDeleteAlso, sometime it's good to leave obvious things on user :)
I am with Rediff.
You have a very good blog that the main thing a lot of interesting and useful!
ReplyDelete