<commit_before># portal

>A micro and fast html template engine
>
>[![Dependencies][david-image]][david-url]

### API

* new Portal(options: Object)
  * params: options { open: Boolean, open: String }
    * open: template open tag
    * close: template close tag
  * return: { register: Function, unregister: Function, compile: Function }
    * register(name: String, helper: Function): register helper
      * name: the name of helper
      * helper: helper method
    * unregister(name: String): unregister helper
      * name: the name of helper
    * compile(template: String): compile a template string
      * template: template string
        * ```:``` call helper
        * ```@``` read template data property
        * ```=``` output html escape string
        * ```==``` output origin string
      * return: { render: Function }
        * render(data: Object): render function
          * data: the template data

### Example

template:
```html
<% @items.forEach(function(item) { %>
  <img src="<%= item.src %>" alt="image" />
  <%== :link(item.href, 'download') %>
<% } %>
```

usage:
```js
// Create a new instance
var portal = new Portal();

// Register helper
portal.register('link', function(href, text) {
  return '<a href="' + href + '" title="' + text + '">' + text + '</a>';
});

// Compile template string
var view = portal.compile(template);

// Render view
console.log(view.render({
  items: [
    { src: 'a.jpg', href: '/download/a.jpg' },
    { src: 'b.jpg', href: '/download/b.jpg' },
    { src: 'c.jpg', href: '/download/c.jpg' }
  ]
}));

// Unregister helper
portal.unregister('link');
```

### License

[MIT](LICENSE)

[david-image]: http://img.shields.io/david/dev/nuintun/portal.svg?style=flat-square
[david-url]: https://david-dm.org/nuintun/portal?type=dev<commit_msg>:art: Adjust code style<commit_after># portal

> A micro and fast html template engine
>
> [![Dependencies][david-image]][david-url]

### API

* new Portal(options: Object)
  * params: options { open: Boolean, open: String }
    * open: template open tag
    * close: template close tag
  * return: { register: Function, unregister: Function, compile: Function }
    * register(name: String, helper: Function): register helper
      * name: the name of helper
      * helper: helper method
    * unregister(name: String): unregister helper
      * name: the name of helper
    * compile(template: String): compile a template string
      * template: template string
        * `:` call helper
        * `@` read template data property
        * `=` output html escape string
        * `==` output origin string
      * return: { render: Function }
        * render(data: Object): render function
          * data: the template data

### Example

template:

```html
<% @items.forEach(function(item) { %>
  <img src="<%= item.src %>" alt="image" />
  <%== :link(item.href, 'download') %>
<% } %>
```

usage:

```js
// Create a new instance
var portal = new Portal();

// Register helper
portal.register('link', function(href, text) {
  return '<a href="' + href + '" title="' + text + '">' + text + '</a>';
});

// Compile template string
var view = portal.compile(template);

// Render view
console.log(
  view.render({
    items: [
      { src: 'a.jpg', href: '/download/a.jpg' },
      { src: 'b.jpg', href: '/download/b.jpg' },
      { src: 'c.jpg', href: '/download/c.jpg' }
    ]
  })
);

// Unregister helper
portal.unregister('link');
```

### License

[MIT](LICENSE)

[david-image]: http://img.shields.io/david/dev/nuintun/portal.svg?style=flat-square
[david-url]: https://david-dm.org/nuintun/portal?type=dev
{'fraction_non_alphanumeric': 0.17754424778761063, 'fraction_numerical': 0.0, 'mean_word_length': 3.225467289719626, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1609158', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1141, 'n_words': 313}