5 ms·
There are templating languages whose primary use case is to generate markup (including XML)[0] and (unless they're broken to uselessness) they should gu
by timdorr 14y ago
There are templating languages whose primary use case is to generate markup
(including XML)[0] and (unless they're broken to uselessness) they should
guarantee the output is valid XML.
Since they are using Rails, they should be using Builder for this: http://api.rubyonrails.org/classes/ActionView/Base.html#label-Builder http://api.rubyonrails.org/classes/ActionView/Base.html#labe... https://github.com/jimweirich/builder https://github.com/jimweirich/builder
- masklinn 14y ago> Since they are using Rails, they should be using Builder for this Indeed. It's really odd that they munged together an XML export in ERB when builder exist. Does it have some sort of breaking issue with namespaces or something which could explain the choice?
- mnarayan01 14y agoBuilder can be a bit of a pain if you want to do things that are...let us say "questionable" (e.g. output a tag with inner content which is _not_ XML escaped).
- masklinn 14y agoThere's no such thing in this case though, there's a single layer of tags with escaped content inside (the example document uses CDATA, but as others have noted automated generation is not a good use case for CDATA)
- mnarayan01 14y agoAgreed; just saying in general. Also, I would guess the reason they used ERB here is simply familiarity, not any type of reasoned decision.
- purephase 14y agoRABL does a pretty decent job at generating XML too.
- jlogsdon 14y agoIf you need layouts RABL falls apart with Ruby 1.9: https://github.com/nesquena/rabl/wiki/Using-Layouts https://github.com/nesquena/rabl/wiki/Using-Layouts there's a note at the of the "Using Rabl" section.