Playground
cowsaydemo.gno
// Package cowsaydemo is a small gnoweb demo of the cowsay renderer provided by
// the [p/moul/x/daily/cowsay](/p/nym-moultest123/x/daily/cowsay/v0) library: it makes the
// ASCII cow say whatever you put in the path.
//
// It contains no rendering logic of its own — the art comes entirely from
// `cowsay.Say`.
package cowsaydemo
import (
"strings"
"gno.land/p/nym-moultest123/x/daily/cowsay/v0"
)
// Render displays the cow for gnoweb.
//
// Render("") -> default message ("Moo!")
// Render("/hello there") -> renders "hello there", word-wrapped
func Render(path string) string {
msg := strings.TrimLeft(path, "/")
art := cowsay.Say(msg)
var b strings.Builder
b.WriteString("# cowsay\n\n")
if strings.TrimSpace(msg) == "" {
b.WriteString("_Tip: pass a message in the path, e.g._ `/Hello, gno.land!`\n\n")
}
b.WriteString("```\n")
b.WriteString(art)
b.WriteString("```\n")
return b.String()
}
gnomod.toml
module = "gno.land/r/nym-moultest123/x/daily/cowsaydemo/v0" gno = "0.9" [addpkg] creator = "g1ml9grtwnpzqn3hre5ve5vjdlmv2srrmpmc0dsv" height = 186410 max_deposit = "5000000ugnot"
render_example_test.gno
package cowsaydemo
// ExampleRender pins the realm's Render output as a gno testable example.
func ExampleRender() {
print(Render(""))
// Output:
// # cowsay
//
// _Tip: pass a message in the path, e.g._ `/Hello, gno.land!`
//
// ```
// ______
// < Moo! >
// ------
// \ ^__^
// \ (oo)\_______
// (__)\ )\/\
// ||----w |
// || ||
// ```
}