andrew4699 / classnames

Simple utility for conditionally joining HTML class names together (based on JedWatson/classnames)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

classnames

Simple utility for conditionally joining HTML class names together (based on JedWatson/classnames)

Install

go get github.com/andrew4699/classnames

Usage

Note that classnames.B is shorthand for classnames.Build

...

import (
    "github.com/andrew4699/classnames"
)

classnames.B("foo", "bar") // "foo bar"
classnames.B([]string{"foo", "bar"}, "duck") // "foo bar duck"
classnames.B(nil, "foo", []string{"bar"}, nil, nil, nil) // "foo bar"

myMap := classnames.Map{
    "foo": true,
    "bar": false,
    "duck": true,
}

classnames.B(myMap) // "foo duck"

...

About

Simple utility for conditionally joining HTML class names together (based on JedWatson/classnames)

License:MIT License


Languages

Language:Go 100.0%