<commit_before>Getting started
===================

First template
--------------------


Create a template file:

```html
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>{$title}</title>
    </head>
    <body>
        <h1>{$title}</h1>
        {@$content}
    </body>
</html>
```

And render it with Node.js:

```javascript
var cutter = require("cutter");

cutter.get("your-template.jtpl", function(err, template) {
    var data = { 
        title: "Hello world",
        content: "<p>The quick brown fox jumps over the lazy dog.</p>"
    };
    var output = template.fetch(data);
});
```<commit_msg>Update getting-started.md<commit_after>Getting started
===================

First template
--------------------


Create a template file:

```html
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>{$title}</title>
    </head>
    <body>
        <h1>{$title}</h1>
        {@$content}
    </body>
</html>
```

And render it with Node.js:

```javascript
var cutter = require("cutter");

cutter.get("your-template.jtpl", function(err, template) {
    var data = { 
        title: "Hello world",
        content: "<p>The quick brown fox jumps over the lazy dog.</p>"
    };
    var output = template.fetch(data);
});
```


How this works?
-------------------

- The template file is parsed and compiled to JavaScript code, then executed with the [vm](http://nodejs.org/api/vm.html) module. Evaluation of the JavaScript code produces a module-like structure which is (repeatedly) used to render the template.
- Template data variables are accessible via `$` prefix - `$title` means `data.title`.
- `{$title}` writes the contents of `data.title`, which is `Hello world`.
- All output is auto-escaped to prevent XSS attacks. However, it can be turned off - `@` modifier in `{@$content}` means that `<p>` and `</p>` won't be converted to `&lt;p&gt;` and `&lt;/p&gt;`.


What else can I do with it?
-----------------

### Comments

```
{* This is a comment *}
```

### Conditions and loops

```
{if $foo === "bar"}
    Foo is bar.
{else}
    Foo is {$foo}.
{/}
```

or

```
{for var i = 0; i < $foo.length; i++}
    $foo[{i}] = {$foo[i]}
{/}
```

### Inline JavaScript

```
{> var localVariable = (function() { /* so something */ })()}
{localVariable}
```


### ...and many other things

- Inheritance and virtual sections
- Template cutouts
- Macros
{'fraction_non_alphanumeric': 0.21348314606741572, 'fraction_numerical': 0.002913025384935497, 'mean_word_length': 2.7503900156006242, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '735348', 'n_tokens_mistral': 808, 'n_tokens_neox': 758, 'n_words': 244}