The render command


render <template> with (<arg list>)



The render command implements a simple template language. This language has two rules:

The result of rendering the template will be stored in the result (or it) variable.

For example, if we want to render a list of colors:

<button _="on click
  render #color-template with (colors: getColors()) then put it into #colors">
  Get the colors

Our template might look like this:

<template id="color-template">
    @repeat in colors
      @set bg to it
      @set fg to getContrastingColor(it)
      <li style="background: ${bg}; color: ${fg}">${bg}</li>

Warning: Hyperscript templates currently perform no HTML escaping. Do not include untrusted (e.g. user-generated) data into your templates.