jinja

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jinja renders minijinja templates: the format-string engine behind every bar module's format key (wayle-shell-core's template.rs, minijinja 2 with its builtins and default settings).

It covers what a format string can use: {{ }} expressions with the full operator set, attribute and item access, slicing, filters and tests, if/elif/else, for loops with the loop variable, set, raw blocks, comments, and whitespace control. Macros, includes, and template inheritance are not part of the Rust build (its minijinja has default features off) and are not here either.

Values are Go data: nil (none), bool, the integer and float kinds, string, slices, and string-keyed maps. Undefined is its own value: it prints as nothing, is falsy, and iterates as empty, and looking an attribute up on it is an error, minijinja's lenient behavior.

Index

Constants

This section is empty.

Variables

View Source
var Undefined any = undefined{}

Undefined is the undefined value.

Functions

func Render

func Render(src string, ctx any) (string, error)

Render renders src with ctx's top-level keys as variables (a map, or nil for none): minijinja's render_str with the default environment.

func RenderOr

func RenderOr(src string, ctx any) string

RenderOr is Render that renders failure as "": the Rust callers' render(...).unwrap_or_default().

Types

type Env

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

Env holds the global functions a template may call; the zero value has the builtins only.

func (*Env) AddFunction

func (e *Env) AddFunction(name string, fn Func)

AddFunction registers a global function (env.add_function).

func (*Env) Render

func (e *Env) Render(src string, ctx any) (string, error)

Render renders src in this environment.

type Error

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

Error is a template syntax or render error.

func (*Error) Error

func (e *Error) Error() string

type Func

type Func func(args []any, kwargs map[string]any) (any, error)

Func is a template global function: positional and keyword arguments in, one value out.

Jump to

Keyboard shortcuts

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