Hello all,
does anyone now how to generate SVG image from rails?
thanks
Hello all,
does anyone now how to generate SVG image from rails?
thanks
You should be able to put SVG in your views but it is tricky (see http://wiki.svg.org/Inline_SVG).
How complex is your SVG. SVG is just XML. You should even be able to use the XML Builder in Rails to generate SVG if you learn the SVG tag set (language). As far as getting browser support, that's a bit trickier. Some browsers are now understanding SVG natively. Among these are Firefox 2.x and Safari v3.0 (I'm sure there are others). If you need to support other browsers that don't understand SVG natively you'll need to make sure your users have a SVG plugin for their browser.
Also from experience, no all browser behave the same with SVG. Some things work on one browser and not on another. Native support for SVG in the browsers that support it is currently incomplete. Here is a page showing the current support in Apple's WebKit (Safari nightly build) The WebKit Open Source Project | WebKit for example.
You can use Rasem https://github.com/aseldawy/rasem to generate SVG images from your ruby source code. Check it out. It's still in Alpha release but it looks good. At least, you can use it now for simple images.
You didn't mention what your application was, but if you're looking for SVG for the purpose of generating a graph, and not just general drawing, you might take a look at ruby-graphviz (https://github.com/ glejeune/Ruby-Graphviz/), which is an interface to graphviz, which will output SVG. It has less flexibility, but it does handle the layout of the graph, which would otherwise be tedious if you had to write it.
\Peter