Current collected state Current
Observed since 20 Oct, 17:44 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
template language based on pug + coffeescript + stylus
A template language that compiles to HTML, CSS, and JavaScript. Combines the best ideas from Pug, Stylus, and CoffeeScript into a single indentation-based syntax.
pip install abstra-sugar
from abstra_sugar import sugar
# static
html = sugar(open("page.sugar").read())
# with data (templating)
html = sugar(open("page.sugar").read(), {"users": [...], "title": "Home"})
html:
head:
style:
.title:
color: #333
font-size: 24px
body:
h1.title: Hello World
p: Welcome to Sugar
ul:
li: Simple
li: Fast
li: Clean
script:
greet(name):
console.log(`Hello, ${name}!`)
greet("World")
Compiles to:
<html>
<head>
<style>
.title {
color: #333;
font-size: 24px;
}
</style>
</head>
<body>
<h1 class="title">Hello World</h1>
<p>Welcome to Sugar</p>
<ul>
<li>Simple</li>
<li>Fast</li>
<li>Clean</li>
</ul>
<script>
function greet(name) {
console.log(`Hello, ${name}!`);
}
greet("World");
</script>
</body>
</html>
| Feature | Sugar | Compiles to |
|---|---|---|
| Element | div: | <div></div> |
| Implicit div | .foo: | <div class="foo"></div> |
| ID shorthand | #main: | <div id="main"></div> |
| Combined | canvas#game.full: | <canvas id="game" class="full"></canvas> |
| Class | div.foo.bar: | <div class="foo bar"></div> |
| Attribute | a href=/about: | <a href="/about"></a> |
| Text | h1: Hello | <h1>Hello</h1> |
| Interpolation | li: {user.name} | <li>Alice</li> (with data) |
| Inline element | td: a href=#: Click | <td><a href="#">Click</a></td> |
| Void element | hr: | <hr> |
| Comment | # ignored | (removed) |
| Template for | for x of arr: | repeats children (with data) |
| Template if | if cond: | conditional render (with data) |
| Implicit child | ul: > : Item | <ul><li>Item</li></ul> |
| CSS property | color: red | color: red; |
| CSS selector | .foo: | .foo { |
| JS function | greet(x): | function greet(x) { |
| JS arrow | (x): | (x) => { |
| JS inline arrow | (x): x * 2 | (x) => x * 2 |
| JS for loop | for x of arr: | for (let x of arr) { |
| JS if | if x > 0: | if (x > 0) { |
| JS class | class Foo: | class Foo { |
| JS object | indented key/values | {key: value, ...} |
| html! literal | html!: + sugar | `<div>...</div>` |
| Component def | card = (title): | (reusable template) |
| Component call | card("Users"): | (expands template) |
| Slot | slot: | (replaced by call children) |
| CSS mixin def | reset = (): | (reusable properties) |
| CSS mixin call | @reset() | (expands properties) |
See the docs folder for the full language reference.
sugar(string) → string
scan(code) → List[Token] # lexer.py
parse(tokens) → List[Node] # parser.py
compile(nodes) → string # compiler.py
MIT — see LICENSE.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.2.0a1 | 21 Mar 2026 | 0 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 17:44 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d1bda084edad1d7eaba405b981a8ae19cba5e8800232d50ff0b1be8161fe59cc