Skip to content

refactor: generate SVGs using HEEx templates, not string concatenation #1

@benswift

Description

@benswift

Currently, all of the SVG generation (which is basically what the PerceptronApparatus.Renderable protocol is all about) is just done with building up & concatenating normal Elixir strings. This happens throughout the whole codebase.

It would be much nicer if instead these SVG fragments were built up using HEEx templates, and only rendered out to a string (or an iolist) at the very last moment. This would give error checking around malformed HTML/SVG, as well as nicer composability.

While HEEx templates are usually associated with the Phoenix web framework, it is possible to just import the ~H sigil like so:

import Phoenix.Component, only: [sigil_H: 2]

and then the various module functions in this repo could instead be function components.

The final SVG output files would be the same as before, but working with this library will be much nicer when this change is implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions