25 lines
455 B
Go
25 lines
455 B
Go
package svg
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type (
|
|
// Attribute is the minimum method set of of an svg attribute.
|
|
Attribute interface {
|
|
// PrintKey must return the svg attribute key
|
|
PrintKey() string
|
|
// PrintVAlue must return the svg attribute value string, if applicable
|
|
PrintValue() (string, bool)
|
|
}
|
|
)
|
|
|
|
func PrintAttribute(a Attribute) string {
|
|
v, ok := a.PrintValue()
|
|
if !ok {
|
|
return a.PrintKey()
|
|
}
|
|
|
|
return fmt.Sprintf("%s=%s", a.PrintKey(), v)
|
|
}
|