Refactor the svg compiling into a factory

The compiling functionality could ideally be used by other custom SVG directives. I separated the functionality that handles compiling of an element into a factory that other directives can inject for reuse.