Cup is a lightweight, flexible, and elegant templating engine written in V. It combines the structure of HTML, the cascading power of CSS, and the interactivity of JavaScript/TypeScript into a single, clean, and expressive syntax β without sacrificing compatibility.
β¨ Write once. Render fast. See clearly.
- β HTML/CSS/JS-inspired syntax β fully compatible with standard tags and attributes
- π‘ Cascading and nested blocks β like CSS, but across markup and logic
- π§ Scoped styles and inline logic β embed behavior within elements
- π Dynamic templating β simple conditionals, loops, and reactive variables (planned)
- βοΈ Transpiles to pure HTML/CSS/JS β no runtime dependencies
- π¦ Built in V β minimal, blazing fast, cross-platform
v install siguici.cupOr directly from GitHub:
v install github.com/siguici/cupbutton {
Click me
style {
@import './global.css';
background: var(--primary-color);
color: white;
padding: 1em;
border-radius: 8px;
&:hover {
background: var(--secondary-color);
}
}
script {
this.addEventListener('click', () => {
alert("Hello from Cup!")
})
}
}
Compiles to:
<button onclick="alert('Hello from Cup!')" style="background:#7878ff;color:white;padding:1em;border-radius:8px;">
Click me
</button>import siguici.cup
fn main() {
html := cup.render_file('examples/hello.cup') or {
eprintln('Error: $err')
return
}
println(html)
}- Basic lexer/parser
- Embedded style and script blocks
- HTML transpilation
- Conditionals (
@if,@else) - Loops (
@for,@each) - Reactive variables (
@var,@watch) - Live preview / runtime renderer (optional)
- Plugin system
Pull requests, feedback, ideas, and questions are welcome!
To contribute:
- Fork this repo
- Clone locally and create a new branch
- Make your changes
- Open a pull request
MIT Β© Sigui KessΓ© Emmanuel