templateLanguage

package
v1.4.4-alpha1202-loadi... Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEndPosition

func GetEndPosition(t antlr.Token) (int, int)

func GetRange

func GetRange(editor *memedit.MemEditor, token CanStartStopToken) *memedit.Range

Types

type CanStartStopToken

type CanStartStopToken interface {
	GetStop() antlr.Token
	GetStart() antlr.Token
	GetText() string
}

type IfBuilder

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

func (*IfBuilder) SetElse

func (ib *IfBuilder) SetElse(block string)

func (*IfBuilder) SetIfCondition

func (ib *IfBuilder) SetIfCondition(condition, block string)

type Instruction

type Instruction struct {
	Opcode     Opcode
	Attributes map[string]string
	Text       string
	Range      *memedit.Range
	// contains filtered or unexported fields
}

type Instructions

type Instructions []*Instruction

type Interpreter

type Interpreter struct {
	Instructions Instructions
	// contains filtered or unexported fields
}

func NewInterpreter

func NewInterpreter(instructions Instructions) *Interpreter

func (*Interpreter) GenerateCode

func (i *Interpreter) GenerateCode() (err error)

func (*Interpreter) GetCurrentLine

func (i *Interpreter) GetCurrentLine() int

func (*Interpreter) GetGeneratedCode

func (i *Interpreter) GetGeneratedCode() string

func (*Interpreter) GetRangeMap

func (i *Interpreter) GetRangeMap() map[int]*memedit.Range

func (*Interpreter) GetTemplate

func (i *Interpreter) GetTemplate() TemplateRender

func (*Interpreter) SetRangeMap

func (i *Interpreter) SetRangeMap()

func (*Interpreter) SetStartLine

func (i *Interpreter) SetStartLine()

func (*Interpreter) SetTemplate

func (i *Interpreter) SetTemplate(template TemplateRender)

type Opcode

type Opcode int
const (
	OpPureText Opcode = iota
	OpOutput
	OpEscapeOutput
	OpPureCode
	OpDeclarationCode
	OpImport
	OpIfStmt
)

type TemplateGeneratedInfo

type TemplateGeneratedInfo interface {
	GetContent() string
	GetClassName() string
	GetPkgName() string
	GetTemplateServerName() string       // run template server's method name
	GetRangeMap() map[int]*memedit.Range // generated code offset -> template language range
}

TemplateGeneratedInfo is the interface for the generated template code

type TemplateRender

type TemplateRender interface {
	WritePureText(text string)         // Just writing text, usually used to write HTML content in templates
	WriteOutput(variable string)       // Write output, usually used to write variables in templates
	WriteEscapeOutput(variable string) // Write variables to the template output, but they will be HTML escaped
	WritePureCode(code string)         // Write pure code, usually used to write code in templates
	WriteImport(path string)           // Write import dependency statement
	WriteDeclaration(code string)
	String() string
	Finish()
}

TemplateRender is the interface for the template render

type TemplateTyp

type TemplateTyp int
const (
	TEMPLATE_JAVA_JSP TemplateTyp = iota
	TEMPLATE_JAVA_FREEMARKER
	TEMPLATE_JAVA_THYMELEAF
)

type TemplateVisitor

type TemplateVisitor interface {
	GetInstructions() Instructions
}

type Visitor

type Visitor struct {
	Instructions Instructions
	CurrentRange *memedit.Range
	Editor       *memedit.MemEditor
}

func NewVisitor

func NewVisitor() *Visitor

func (*Visitor) EmitDeclarationCode

func (y *Visitor) EmitDeclarationCode(code string)

func (*Visitor) EmitEscapeOutput

func (y *Visitor) EmitEscapeOutput(variable string)

func (*Visitor) EmitIfStatement

func (y *Visitor) EmitIfStatement(builder *IfBuilder)

func (*Visitor) EmitImport

func (y *Visitor) EmitImport(path string)

func (*Visitor) EmitOutput

func (y *Visitor) EmitOutput(variable string)

func (*Visitor) EmitPureCode

func (y *Visitor) EmitPureCode(code string)

func (*Visitor) EmitPureText

func (y *Visitor) EmitPureText(text string)

func (*Visitor) GetInstructions

func (y *Visitor) GetInstructions() Instructions

func (*Visitor) NewIfBuilder

func (y *Visitor) NewIfBuilder() *IfBuilder

func (*Visitor) SetRange

func (y *Visitor) SetRange(token CanStartStopToken) func()

type VisitorCreator

type VisitorCreator interface {
	Create(editor *memedit.MemEditor) (TemplateVisitor, error)
}

Jump to

Keyboard shortcuts

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