<commit_before># Karver

Karver is a template engine written in Haskell, and the syntax is
heavily inspired by [jinja2][1].

The project is in early development, so it isn't as full featured or
production ready as jinja is. However, karver's main focus is for
Haskell programmers, wanting a template engine that is simple and has
good performance.

A small taste of the syntax being:

```
{% if title %}
<h1 id="{{ title }}">{{ title }}</h1>
{% endif %}

<ul>
{% for item in items %}
  <li>{{ item }}</li>
{% endfor %}
</ul>
```

[1]: http://jinja.pocoo.org/<commit_msg>Add interface example of progamming with karver<commit_after># Karver

Karver is a template engine written in Haskell, and the syntax is
heavily inspired by [jinja2][1].

The project is in early development, so it isn't as full featured or
production ready as jinja is. However, karver's main focus is for
Haskell programmers, wanting a template engine that is simple and has
good performance.

A small taste of the syntax being:

```
{% if title %}
<h1 id="{{ title }}">{{ title }}</h1>
{% endif %}

<ul>
{% for item in items %}
  <li>{{ item }}</li>
{% endfor %}
</ul>
```

# Interface of Karver

The meat of karver is the `renderTemplate` function. With it's type
signature being, `renderTemplate :: HashMap Text Value -> Text -> Text`,
it takes a hashmap of variables being used by the template, and the
template text itself. It of course returns the translated result, and
since the type is `Text`, it supports Unicode right out of the box.

Programs using karver might look something like:

```haskell
import Text.Karver
import qualified Data.HashMap.Strict as H
import qualified Data.Text.IO as T
import qualified Data.Vector as V

templateHashMap :: HashMap Text Value
templateHashMap = H.fromList $
  [ ("title", Literal "Grocery List")
  , ("items", List $ V.fromList
                ["eggs", "flour", "cereal"])
  ]

main :: IO ()
main = do
  tplStr <- T.readFile "path/to/template.html"
  let htmlStr = renderTemplate _ tplStr
  T.writeFile "path/to/output.html"
```

[1]: http://jinja.pocoo.org/
{'fraction_non_alphanumeric': 0.11790182868142444, 'fraction_numerical': 0.004812319538017324, 'mean_word_length': 3.9975961538461537, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2576087', 'n_tokens_mistral': 682, 'n_tokens_neox': 627, 'n_words': 282}