^  _  ^

Platelet is an HTML-first templating language.

Modern alternative to handlebars/Jinja for Rust.

Simple and intuitive behaviour

Platelet uses a small superset of JSON for expressions and HTML attributes for rendering.

<img ^src='article.img_url'>
    <a ^href='article.link'>{{title}}</a>
  <div pl-html='summary'></div>

Works with existing HTML tools

Platelet uses HTML attributes for its syntax - so you can bring your own formatter and tooling.

<ul pl-if="list">
  <li pl-for="item in list">
    {{ item }}

<p pl-else>no items</p>

Break templates into small Components

Support for named slots & importing templates out of the box.

  ^action='"/submit/" + uuid'>
  <b>Approve<b> changes

<!-- button.html -->
<button ^formaction='action'>
  <slot pl-slot></slot>

Works great with htmx & Alpine.js

Combine platelet for server side rendering with htmx and/or Alpine.js for interactivity.

<tr pl-for='(contact, i) in contacts'
    ^hx-get='i > 9 && "/contacts/?page=" + next'
  <td>{{ contract.name }}</td>
  <td>{{ contract.email }}</td>
  <td>{{ contract.id }}</td>

<style> & <script> de-duplication

Identical scripts and stylesheets are combined so you can co-locate your components, styles and behaviour.

<template pl-for="input in inputs">
  <textarea data-input></textarea>
    textarea { border-color: green; }
      .forEach( /* ... */ )