// Attribute renders an Attribute to it's HTML string representation
// While it's possible to have attributes without values it simplifies things if we always have a value
Attribute renders an Attribute to it's HTML string representation
While it's possible to have attributes without values it simplifies things if we always have a value
// Attribute renders an Attribute to it ' s HTML string representation // While it ' s possible to have attributes without values it simplifies things if we always have a value
func (r *Renderer) Attribute(attrs []Attributer, w io.Writer) error {
	if len(attrs) == 0 {
		return nil
	}
	for i := 0; i < len(attrs); i++ {
		attrStr := fmt.Sprintf(` %s="%s"`, attrs[i].GetAttribute().Name, attrs[i].GetAttribute().GetValue())
		if _, err := w.Write([]byte(attrStr)); err != nil {
			return fmt.Errorf("write: %w", err)
		}
	}
	return nil
}
func ( r * Renderer ) Attribute ( attrs [ ] Attributer , w io . Writer ) error { if len ( attrs ) == 0 { return nil } for i := 0 ; i < len ( attrs ) ; i ++ { attrStr := fmt . Sprintf ( ` %s="%s"` , attrs [ i ] . GetAttribute ( ) . Name , attrs [ i ] . GetAttribute ( ) . GetValue ( ) ) if _ , err := w . Write ( [ ] byte ( attrStr ) ) ; err != nil { return fmt . Errorf ( " " , err ) } } return nil }
Attribute renders an Attribute to it's HTML string representation
While it's possible to have attributes without values it simplifies things if we always have a value
Attribute renders an Attribute to it ' s HTML string representation While it ' s possible to have attributes without values it simplifies things if we always have a value