<commit_before># JSIN - Javascript Include

Template engine for use at server and client side.

## Features

- Well-known PHP-like syntax.
- Accurate quote parsing.
- Asynchronous compiling of templates on the fly.
- Pre-compiling for use in browser.

## Usage

### Syntax

Constructions:

- `<?js /* any javascript code */ ?>`
- `<?= /* print value or result of expression */ ?>`

Functions:

- `print(string)`
- `include(template, [data])`
- `layout(template, [data], callback)`
- `contents()`

### Example

```html
<!-- mytemplate.jsin -->
<h1>Example</h1>
<p>
    <?= "Check ?>'\" special chars and variable " + boo ?>
</p>
<p>
    <?js if (1 === 1) { ?>
        1 === 1
    <?js } else { ?>
        1 !== 1
    <?js } ?>
</p>
<?js

include('include');

print("<p>Example print</p>\n");

?>
<?js layout('layout', function(){ ?>
        <div>
            <p>Example layout inside</p>
            <?js include('layout-include-inside') ?>
        </div>
<?js }) ?>

<p>Thanx!</p>
```

```html
<!-- layout.jsin -->
<div>
    <p>Example layout begin with variable <?= boo ?></p>
    <div>
        <?js contents() ?>
    </div>
    <?js include('layout-include') ?>
    <p>Example layout end</p>
</div>
```

### Server side

```js
var include = require('jsin').include;

# you can omit extension .jsin or .js
include('mytemplate', {
    boo: 'booooooo'
}, function(err, res) {
    if (err) {
        console.log('Error: ' + err);
    } else {
        console.log(res);
    }
});
```

### Client side

Compile client-side script using `jsinc` command-line tool:

```sh
$ jsinc path/to/*.jsin jsin.compiled.js
```

Additional options:

- `-b` - beautify
- `-u` - uglify

In browser:

```html
<script src="jsin.compiled.js"></script>
<script>
    var res = jsin.include('mytemplate', {
        boo: 'booooo'
    });
    document.getElementById('res').innerHTML = res;
</script>
```

## License

Copyright © 2014 <NAME> <<EMAIL>>

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/.
<commit_msg>readme fix<commit_after># JSIN - Javascript Include

Template engine for use at server and client side.

## Features

- Well-known PHP-like syntax.
- Accurate quote parsing.
- Asynchronous compiling of templates on the fly.
- Pre-compiling for use in browser.

## Usage

### Syntax

Constructions:

- `<?js /* any javascript code */ ?>`
- `<?= /* print value or result of expression */ ?>`

Functions:

- `print(string)`
- `include(template, [data])`
- `layout(template, [data], callback)`
- `contents()`

### Example

```html
<!-- mytemplate.jsin -->
<h1>Example</h1>
<p>
    <?= "Check ?>'\" special chars and variable " + boo ?>
</p>
<p>
    <?js if (1 === 1) { ?>
        1 === 1
    <?js } else { ?>
        1 !== 1
    <?js } ?>
</p>
<?js

include('include');

print("<p>Example print</p>\n");

?>
<?js layout('layout', function(){ ?>
        <div>
            <p>Example layout inside</p>
            <?js include('layout-include-inside') ?>
        </div>
<?js }) ?>

<p>Thanx!</p>
```

```html
<!-- layout.jsin -->
<div>
    <p>Example layout begin with variable <?= boo ?></p>
    <div>
        <?js contents() ?>
    </div>
    <?js include('layout-include') ?>
    <p>Example layout end</p>
</div>
```

### Server side

```js
var include = require('jsin').include;

// you can omit extension .jsin or .js
include('mytemplate', {
    boo: 'booooooo'
}, function(err, res) {
    if (err) {
        console.log('Error: ' + err);
    } else {
        console.log(res);
    }
});
```

### Client side

Compile client-side script using `jsinc` command-line tool:

```sh
$ jsinc path/to/*.jsin jsin.compiled.js
```

Additional options:

- `-b` - beautify
- `-u` - uglify

In browser:

```html
<script src="jsin.compiled.js"></script>
<script>
    var res = jsin.include('mytemplate', {
        boo: 'booooo'
    });
    document.getElementById('res').innerHTML = res;
</script>
```

## License

Copyright © 2014 <NAME> <<EMAIL>>

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/.

{'fraction_non_alphanumeric': 0.1961014560826679, 'fraction_numerical': 0.007515265382808831, 'mean_word_length': 2.8231597845601435, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '155766', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1462, 'n_words': 423}