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.61 Kb · 27 lines
 1package render
 2
 3import "strings"
 4
 5func Hello() string {
 6	return "Hello World!"
 7}
 8
 9func greetings(name string) string { // private
10	return "Welcome, " + name + "!"
11}
12
13func Render(path string) string {
14	switch {
15	case path == "hello":
16		return Hello()
17	case strings.HasPrefix(path, "greetings/"):
18		name := strings.Split(path, "/")[1] // take string after slash
19		name = strings.Title(name)          // capitalize first letter
20		return greetings(name)
21	case path == "":
22		out := "- [hello](/r/moul_basics_004:hello)\n"
23		out += "- [greetings/Manfred](/r/moul_basics_004:greetings/Manfred)\n"
24		return out
25	}
26	return "404"
27}