ex03

package
v0.0.0-...-1543a3a Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright (C) 2024 early (LGPL)

Index

Constants

This section is empty.

Variables

View Source
var Page = page.New("ex01", "page.html",

	page.Includes(RandomGenerator, parts.SourcePreview),
	page.OnLoad(func(data render.Data) error {

		sources := make(render.Data)
		sources.Set("random_generator_html", include.File("random-generator.html"))
		sources.Set("random_generator_go", include.File("random-generator.go"))
		sources.Set("page", include.File("page.html"))
		sources.Set("go", include.File("example.go"))
		data.Set("sources", sources)
		return nil
	}),
)
View Source
var RandomGenerator = part.New("random-generator", "random-generator.html",
	part.OnLoad(func(data render.Data) error {

		max := 100
		inputMax := data.Get("max")
		if inputMax, ok := inputMax.(string); ok {
			max, _ = strconv.Atoi(inputMax)
		}
		data.Set("number", rand.Int()%max)
		return nil
	}),
)

Like pages, you make parts with part.New. The name is more important for parts, since the name is the name of the element in HTML.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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