hanako-eo / viper

A tiny template engine for v

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Viper

A tiny template engine for v

It's pronounced like the french word vipère /vi.pɛʁ/

Installation

v install --git https://github.com/hanako-eo/viper.git

Usage

In main.v:

module main

import viper

fn main() {
	mut engine := viper.new()
	engine.add_tag(
		name: "block",
		handle: fn(_args string, value string) string {
			return value
		}
	)
	println(
		engine.render("./example.html", map[string]string{}) // If in example.html you have error, it will be shown and exit.
	)
}

In example.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Viper Example</title>
</head>
<body>
  {[ block ]}
    a
  {[ endblock ]}
</body>
</html>

Example of possible error

example of possible error image

License

See the LICENSE file

About

A tiny template engine for v

License:MIT License


Languages

Language:V 100.0%