vingo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 10 Imported by: 1

README

Vingo

⚡️ What is Vingo?

Vingo is a modern template engine developed under the Flint Framework. it provides a fast, flexible, and clean way to render templates in Golang,with full entegration into Flint.


⚙️ Installation

go get github.com/coderianx/vingo

🚀 Quick Start

package main

import (
	"net/http"
    
    "github.com/coderianx/vingo"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/html; charset=utf-8")

        tmpl, err := vingo.Render("index.html", map[string]interface{}{
            "title": "Welcome to Vingo",
            "message": "Hello, Vingo!",
        })
        if err != nil {
            http.Error(w, err.Error(), http.StatusInternalServerError)
            return
        }

		w.Write([]byte(html))
	})

	http.ListenAndServe(":8080", nil)
}

Template Example (index.html)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><{ title }></title>
</head>
<body>
    <h1><{ message }></h1>
</body>
</html>

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AutoEscape = true

AutoEscape: template motoru değişken çıktılarında varsayılan olarak HTML kaçışını (escaping) aktifleştirir. Bunu false yaparak global olarak otomatik kaçışı kapatabilirsiniz (önerilmez).

Functions

func Render

func Render(file string, data map[string]interface{}) (string, error)

Render: template dosyasını oku, compile et (gerekirse cache'den), ve işle

Types

type ForNode

type ForNode struct {
	IndexVar string // optional, can be ""
	ItemVar  string
	ListExpr string
	Body     []Node
}

func (*ForNode) Eval

func (n *ForNode) Eval(data map[string]interface{}) string

type IfBranch

type IfBranch struct {
	Expr string
	Body []Node
}

type IfNode

type IfNode struct {
	Branches []IfBranch
	Else     []Node
}

func (*IfNode) Eval

func (n *IfNode) Eval(data map[string]interface{}) string

type Node

type Node interface {
	Eval(data map[string]interface{}) string
}

type SwitchCase

type SwitchCase struct {
	Cond string
	Body []Node
}

type SwitchNode

type SwitchNode struct {
	Expr    string
	Cases   []SwitchCase
	Default []Node
}

func (*SwitchNode) Eval

func (n *SwitchNode) Eval(data map[string]interface{}) string

type Template

type Template struct {
	Filepath string
	Nodes    []Node
	ModTime  time.Time
}

type TextNode

type TextNode struct {
	Text string
}

func (*TextNode) Eval

func (n *TextNode) Eval(data map[string]interface{}) string

type Token

type Token struct {
	Type    TokenType
	Value   string // for Var: expression or name; for If/For/Switch/Case: expression / raw
	Default string // for Var default literal (if provided)
	Raw     string // raw tag text
}

type TokenType

type TokenType int
const (
	TText TokenType = iota
	TVar
	TIf
	TElseIf
	TElse
	TEndIf
	TFor
	TEndFor
	TSwitch
	TCase
	TDefault
	TEndSwitch
)

type VarNode

type VarNode struct {
	Name    string
	Default string
	Filters []string
}

func (*VarNode) Eval

func (n *VarNode) Eval(data map[string]interface{}) string

Jump to

Keyboard shortcuts

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