Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnridesabike/acutis
A declarative, type-safe template language
https://github.com/johnridesabike/acutis
compiler eleventy handlebars mustache nunjucks ocaml template-engine template-language
Last synced: 2 months ago
JSON representation
A declarative, type-safe template language
- Host: GitHub
- URL: https://github.com/johnridesabike/acutis
- Owner: johnridesabike
- License: mpl-2.0
- Created: 2020-11-30T16:27:31.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-14T12:56:18.000Z (8 months ago)
- Last Synced: 2024-04-14T13:11:15.357Z (8 months ago)
- Topics: compiler, eleventy, handlebars, mustache, nunjucks, ocaml, template-engine, template-language
- Language: OCaml
- Homepage: https://johnridesa.bike/acutis/
- Size: 6.6 MB
- Stars: 20
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - acutis
README
## Acutis language
Acutis is a template language that features static typing, pattern matching, and
asynchronous template components. You can execute your templates like scripts or
compile them to self-contained JavaScript files.Acutis is an experimental, personal project and is not stable.
```acutis
{% interface
siteTitle = string
blogPosts =
[
{
title: string,
author: {name: ?string},
date: string,
image: ?{alt: string, src: string},
content: string
}
]
~%}Blog posts for {% siteTitle %}
{%~ map blogPosts with {image, title, content, date, author: {name}} %}
{% match image with null ~%}
{* no image *}
{%~ with !{src, alt} ~%}
{% /match ~%}
{% title %}
Posted on {% date %}
{{% content %}}
{%~ /map %}
```[See how this example compiles in the playground][example].
[example]:
https://johnridesa.bike/acutis/playground/?props=ewogICJzaXRlVGl0bGUiOiAiTXkgQmxvZyIsCiAgImJsb2dQb3N0cyI6IFsKICAgIHsKICAgICAgInRpdGxlIjogIk15IHNlY29uZCBwb3N0IiwKICAgICAgImF1dGhvciI6IHsgIm5hbWUiOiAiSm9obiIgfSwKICAgICAgImRhdGUiOiAiMjAyMC0xMi0wMSIsCiAgICAgICJpbWFnZSI6IG51bGwsCiAgICAgIC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V9IDwvaDI%2BCiAgICAgIDxzcGFuIGNsYXNzPSJwLWF1dGhvciI%2BIEJ5IHslIG5hbWUgPyAiQW5vbnltb3VzIiAlfSA8L3NwYW4%2BCiAgICAgIDxzcGFuIGNsYXNzPSJkdC1wdWJsaXNoZWQiPiBQb3N0ZWQgb24geyUgZGF0ZSAlfSA8L3NwYW4%2BCiAgICA8L2hlYWRlcj4KICAgIDxkaXYgY2xhc3M9ImUtY29udGVudCI%2BIHt7JSBjb250ZW50ICV9fSA8L2Rpdj4KICA8L2FydGljbGU%2BCnslfiAvbWFwICV9
[Read the documentation here](https://johnridesa.bike/acutis/).## Usage in OCaml
The Acutis source is written in OCaml. You can install it with the OCaml package
manager, OPAM.```shell
opam pin https://github.com/johnridesabike/acutis.git
```## JavaScript & Eleventy plugin
You can use npm to install a JavaScript build of Acutis. This includes an
[Eleventy] plugin.[eleventy]: https://www.11ty.dev/
Install the JavaScript package in your project:
```shell
npm install acutis-lang
```Import the package in your Eleventy-powered site:
```javascript
const acutis = require("acutis-lang");
const acutisEleventy = require("acutis-lang/eleventy");
```## Development
Clone this repository with git. Then create a development OPAM switch:
```shell
opam switch create . --deps-only --with-test --with-doc
```Compile the code:
```shell
dune build
```Run tests:
```shell
dune runtest
```## License
Copyright (c) 2022 John Jackson.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.