preprocess

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package preprocess implements the @include preprocessor. A /*%! @include name */ parser comment is replaced, recursively, by the named fragment's raw text — producing a fully expanded (still 2-way) template that is then lexed/parsed/rendered normally. Because the directive rides on the /*%! ... */ parser-comment channel, a raw template pasted into a SQL client treats it as a comment (the base SQL runs without the fragment).

Index

Constants

View Source
const DefaultMaxDepth = 50

DefaultMaxDepth bounds recursive expansion (a backstop beyond cycle detection).

Variables

This section is empty.

Functions

func Expand

func Expand(src string, resolve Resolver) (string, error)

Expand replaces every /*%! @include name */ in src with the resolved fragment text, recursively. It is string- and comment-aware (an @include inside a '...' literal or a -- line comment is left untouched). Cyclic references and unknown fragments error.

Types

type Resolver

type Resolver func(name string) (string, error)

Resolver returns the raw text of a named fragment, or an error if unknown.

Jump to

Keyboard shortcuts

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