vector_inspector

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 8 Imported by: 0

README

Dyntpl vector bindings

Provide vector and vector_inspector features to use in dyntpl templates.

Usage
package main

import (
	"github.com/koykov/dyntpl"
	_ "github.com/koykov/dyntpl_vector"    // register vector bindings
	_ "github.com/koykov/vector_inspector" // register vector inspector
)

const (
	tpl = `{% ctx data = vector::parseJSON(source).(vector) %}
output: {%= data.x.y.z %}`
	json = `{"x":{"y":{"z":"foobar"}}}`
)

func main() {
	tree, _ := dyntpl.Parse([]byte(tpl), false)
	dyntpl.RegisterTplKey("example", tree)
	ctx := dyntpl.NewCtx()
	ctx.SetString("source", json)
	result, _ := dyntpl.Render("example", ctx)
	println(string(result)) // output: foobar
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownType = errors.New("unknown vector type")

Functions

func VectorNodeEmptyCheck

func VectorNodeEmptyCheck(_ *dyntpl.Ctx, val any) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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