Skip to content

Releasing hop 0.2

hop is a component-based template language that compiles to plain Rust. The goal of hop is to bring performant server-side rendering of components (à la JSX/TSX) to Rust with end-to-end type-safety. When using hop, you declare your front-end code in .hop files, run the hop compiler and get .rs files out.

This release lands two major features: type checking of HTML attributes and forwarding of attributes via spreads. It also includes a few quality-of-life improvements and performance improvements.

Type checking of HTML attributes

As of this release hop performs proper type-checking of HTML attributes. Invalid use of HTML attributes (e.g. using the href attribute on a button) now gives a type error in the compiler and the language server.

Rest spreads

Components can now forward attributes to an element or another component via a ...rest parameter. This makes it straightforward to write wrapper components for native HTML elements.

The ...rest parameter is fully type-safe. For example, using the href attribute on a component that forwards its attributes to a <button> is a type error.

Try it out in the playground below. Note: this playground uses the browsers native Popover API for interactivity.

Smaller improvements

  • Improvements to slots

This release introduces the Fragment type and slots are now declared using the parameter declaration children: Fragment. Values of the Fragment type are first-class and can be passed around, referenced and stored just like any other value.

  • Type inference for let

Let bindings now infer their type. This makes type annotations optional when the type can be inferred from the context.

  • Better diagnostics for type errors

Error messages for type errors have been reworked to be clearer and more consistent.

Get started

Install hop and try it out: