Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

contract.gno

0.69 Kb · 31 lines
 1package render
 2
 3import (
 4	"strings"
 5
 6	"gno.land/p/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/kit/ui/v0"
 7)
 8
 9func Hello() string {
10	return "Hello World!"
11}
12
13func greetings(name string) string { // private
14	return "Welcome, " + ui.Inline(name) + "!"
15}
16
17func Render(path string) string {
18	switch {
19	case path == "hello":
20		return Hello()
21	case strings.HasPrefix(path, "greetings/"):
22		name := strings.Split(path, "/")[1] // take string after slash
23		name = strings.Title(name)          // capitalize first letter
24		return greetings(name)
25	case path == "":
26		out := "- [hello](/r/moul_basics_004:hello)\n"
27		out += "- [greetings/Manfred](/r/moul_basics_004:greetings/Manfred)\n"
28		return out
29	}
30	return "404"
31}