<commit_before># comps
An components template language in server side render.

## Usage

Install
```bash
npm i comps --save
```

```js
var comps = require('comps')
comps.componentLoader(function (name) {
    return fs.readFileSync(__dirname + '/c/' + name + '/' + name + '.tpl')
})
comps({
    template: '<div>{% component $id="header" /%}</div>'
})
```

## Render Options

- **template** `<String>`
    render html template.

- **pagelet** `<String>`
    Will renderd pagelet id.

## API

- **.config(conf)**
    * openTag `<String>` 
        Open-tag token, such as "{%"

    * closeTag `<String>` 
        Close-tag token, such as "%}"

- **.tag(name, def)**
    name `<String>`
        Tag name, using as "{% xxtag /%}" or "{% xxtag %}{%/ xxtag %}"

    * def `<Object>`
        Tag configuration. Options:

        - scope   `<Boolean>`  
            Whether create a child-scope for the tag.

        - block   `<Boolean>`  
            Whether block tag. Such as: "{%tag%}{%/tag%}".

        - created `<Function>` 
            Call when tag is created.

        - render  `<Function>` 
            Call when tag is rendered. Must **return** Array with two items, item1 is the open tag, item2 is the close tag. 

        - walk    `<Function>` 
            Call when tag's child template is rendered. Must **return** String.

- **.compile(tpl)**
    * tpl `<String>`
        preRender template
    * return `<Function>`

- **.componentLoader(loader)**

- **.componentTransform(transform)**

## Tags

- **component**

Example:
```html
{% component $id="header" /%}
```

Attributes:

    - $id
    - $tag
    - $replace

- **pagelet**

Example:
```html
{% pagelet $id="header" $wrap=false /%}
    <div class="header"></div>
{%/ pagelet %}
```

Attributes:

    - $id
    - $tag
    - $wrap<commit_msg>update doc<commit_after># comps
An components template language in server side render.

## Usage

Install
```bash
npm i comps --save
```

```js
var comps = require('comps')
comps.componentLoader(function (name) {
    return fs.readFileSync(__dirname + '/c/' + name + '/' + name + '.tpl')
})
comps({
    template: '<div>{% component $id="header" /%}</div>'
})
```

## Render Options

- **template** `<String>`
    render html template.

- **pagelet** `<String>`
    Will renderd pagelet id.

## API

- **.config(conf)**
    * openTag `<String>` 
        Open-tag token, such as "{%"

    * closeTag `<String>` 
        Close-tag token, such as "%}"

- **.tag(name, def)**
    name `<String>`
        Tag name, using as "{% xxtag /%}" or "{% xxtag %}{%/ xxtag %}"

    * def `<Object>`
        Tag configuration. Options:

        - scope   `<Boolean>`  
            Whether create a child-scope for the tag.

        - block   `<Boolean>`  
            Whether block tag. Such as: "{%tag%}{%/tag%}".

        - created `<Function>` 
            Call when tag is created.

        - render  `<Function>` 
            Call when tag is rendered. Must **return** Array with two items, item1 is the open tag, item2 is the close tag. 

        - walk    `<Function>` 
            Call when tag's child template is rendered. Must **return** String.

- **.compile(tpl)**
    * tpl `<String>`
        preRender template
    * return `<Function>`

- **.componentLoader(loader)**

- **.componentTransform(transform)**

## Tags

- **component**

Example:
```html
{% component $id="header" /%}
```

Attributes:

    - $id
    - $tag
    - $replace

- **pagelet**

Example:
```html
{% pagelet $id="header" $wrap=false /%}
    <div class="header"></div>
{%/ pagelet %}
```

Attributes:

- $id
- $tag
- $wrap
{'fraction_non_alphanumeric': 0.18293021962746733, 'fraction_numerical': 0.0011120378092855157, 'mean_word_length': 2.3879472693032016, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '846770', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1165, 'n_words': 340}