lemur

package module
v2.0.0-...-d9fcae1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

README

Lemur

A templating helper library

Theme directory structure

Directories starting with an '_' underscore are known, expected, files.

theme_name/
├── layouts/
│   ├── _defaults/
│   │   ├── _index.html
│   │   ├── author-by-line.html
│   │   ├── date.html
│   │   └── figure.html
│   ├── template_name/
│   │   └── _main.html
│   ├── second_template_name/
│   │   ├── _index.html
│   │   └── my-rando-file.html
│   └── _public/
└── Readme.md

Minimal theme

The most minimal theme is one that is just the defaults

theme_name/
└── layouts/
    └── _defaults/
        └── _index.html.tmpl

Documentation

Overview

Package Lemur is a theme templating tool.

Index

Constants

View Source
const (
	ErrThemesBaseDir = Error("lemur: error the supplied theme directory no themes found")
	ErrTemplateDir   = Error("lemur: error with supplied template directory")
)

Errors returned by the api.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Site Site
	Page Page
}

type Error

type Error string

Error is the base error type for api errors.

func (Error) Error

func (e Error) Error() string

type Lemur

type Lemur struct {
	// contains filtered or unexported fields
}

func New

func New(templateFS fs.FS, userFuncs template.FuncMap) (Lemur, error)

New creates a theme render with the themes at the supplied filesystem and the func maps.

func (*Lemur) Render

func (lemur *Lemur) Render(w io.Writer, themeName string, tmplName string, data interface{}) error

Render executes the specified template by name, writing the output to the provided io.Writer.

tmplName specifies which named layout set to use (e.g., "_defaults", "mytemplate"). If tmplName is an empty string, it defaults to "_defaults". The method will then execute the "_index.html.tmpl" template within that layout set.

data is the data to be passed to the template for rendering.

This is the primary method for rendering templates when you have an output stream, such as an http.ResponseWriter or a file.

func (*Lemur) Srender

func (lemur *Lemur) Srender(themeName string, tmplName string, data interface{}) (string, error)

Srender renders the specified template by name with the given data and returns the output as a string.

It is a convenience wrapper around the Render method. Use Srender when you need the template output as a string, for example, to pass to another function, store in a variable, or when an io.Writer is not readily available. If direct writing to an output stream (like an http.ResponseWriter) is possible, using Render directly might be more efficient as it avoids the intermediate string allocation.

type Page

type Page struct {
	Title string
	Data  map[string]interface{}
	Form  map[string]interface{}
}

type Site

type Site struct {
	BaseURL *url.URL

	Title     string
	Copyright string
}

type Theme

type Theme struct {
	ThemeMetaData
	// contains filtered or unexported fields
}

type ThemeMetaData

type ThemeMetaData struct {
	Name        string
	Description string
	Version     string
	Tags        []string
	Author      string
	AuthorURI   url.URL
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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