3 ms·
You can't just agree on syntax, IMHO the reason for that is the best template languages have the full language available. You need a full-language for a great t
by andrewvc 16y ago
You can't just agree on syntax, IMHO the reason for that is the best template languages have the full language available. You need a full-language for a great template language. Smarty, for instance, sucks. HAML, which is terse, but has access to the full syntax of ruby rocks. You can do things like:
= @users.map {|u| sprintf("%04d: %s",u.id, u.status.capitalize)}.join(', ')
Sure there's some special operator is smarty to do this, but I don't want to have to learn it, and they're always more clunky.
Additionally, I always hit complex, weird situations where I need a full-language, and migrating that logic out of the view makes no sense. For instance, I was working on a site where I had repeating content, with ads at predetermined offsets. I rendered it something like:
ads_positions = Set.new(2,8,10,12)
content.each_with_index do |content,i|
if ad_positions.include?(i)
content
ad
else
content
end
end
I hate expressing that stuff server-side or in half-baked templating languages.