jatinder saundh writes:
What could I possibly do to make rails understand that my .rhtml file
acutally an .xhtml file with inline svg? or is there any other way I
use inline svg’s in rails?
Firefox 1.5 will only handle inline SVG correctly in responses that
were served with a content-type of “application/xhtml+xml”, not in
files that were served as “text/html”. On the other hand, IE gags on
responses served that way completely. So, for my IvyGIS maps with
SVG/VML overlays, I wind up doing this, in a protected method in
application.rb which is invoked by controllers:
# We want to display graphic overlays, as inline SVG if possible.
# For inline SVG to work, Firefox requires that the page be marked
# in the HTTP header as containing "application/xhtml+xml". But
# IE gags on that. So, we export that content-type only to browsers
# that explicitly advertise that they support it.
@headers['Content-Type'] = "application/xhtml+xml; charset=utf-8"
Note that if you do this, Firefox (or the other Gecko-based browser
of your choice) will be a lot stricter about other things, and some
of your other helpers may trip over that.
Working examples available, once again, here:
An alternative might be to use embedded SVG — that is, an
tag which makes the browser make a second request for pure SVG. That
works just fine in views served as plain HTML. The problem with that
is that the SVG is treated as part of a logically separate document
for scripting purposes (like HTML loaded into an