customfunc

command
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

README

Cryptographically secure pseudorandom number generator in Sass. Well that is easy to do with this custom crypto() handler!

Start by registering a Sass function with the name crypto(). Now when crypto() is found in Sass, the cryptotext Go function will be called.

Input

div { text: crypto(); }

Output

div {
  text: 'c91db27d5e580ef4292e'; }

Sass function written in Go

func cryptotext(ctx context.Context, usv libsass.SassValue) (*libsass.SassValue, error) {

	c := 10
	b := make([]byte, c)
	_, err := rand.Read(b)
	if err != nil {
		return nil, err
	}
	res, err := libsass.Marshal(fmt.Sprintf("'%x'", b))
	return &res, err
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL