Render SVG in view

I’d like to render a nested hash as a tree SVG inside a view. It’s
becoming cumbersome to write the hash traversing inside the view.

Is the appropriate location for the SVG generation inside a controller?
If so, should I respond_to formal.xml? I would then call the SVG
generation action from inside the view.

I know there are various ways of doing this, I’m just curious what the
standard choice is.

Alexander F. wrote in post #1072914:

I’d like to render a nested hash as a tree SVG inside a view. It’s
becoming cumbersome to write the hash traversing inside the view.

Is the appropriate location for the SVG generation inside a controller?
If so, should I respond_to formal.xml? I would then call the SVG
generation action from inside the view.

I know there are various ways of doing this, I’m just curious what the
standard choice is.

Not knowing all the details of what you’re doing, I would most likely
separate the SVG generation code entirely from both the view and the
controller. SVG is a graphic. I would treat it as an object (or object
graph) unto itself. Your controller would then ask for the data (i.e.
the SVG rendering code) and update the view. That’s the responsibility
of the controller, nothing more.