<commit_before># Mistigri.js
JavaScript template engine inspired by Mustache.

It could be called an antinome of Handlebars, extending Mustache 
without the addition of new keywords.
The main new concept is that of arguments.


Supported features
-------

~~~
{{name}}
~~~

  Inserts the value associated with name in the model.
  
  When the value is null or undefined the default value is inserted. 
  If none is specified then a generic placeholder text is inserted.
  
  Nested values are allowed, for example "person\.name".
  
  If the name is associated with a function then this function is
  called to provide a value. See also Configuration Options.
  
~~~
{{name argument = value}}
~~~

  Provides an argument with a value.
  
  The "default" argument is used when the value associated with name
  is null or undefined.
  
  For boolean values the arguments "yes" and "no" provide the text to 
  insert.
  
  For function values the arguments are passed as an object.
  
  The value provided for the argument can be a number, a string within
  quotes or a name in the model.
  
~~~
{{&name}}
~~~

  Same as ``{{name}}`` except the value is not escaped.
  
  The default escape function is designed to safely insert text in an
  HTML document.
  
~~~
{{#name}}...{{/name}}
~~~

  Inserts the text between the tags depending on the value associated
  with name:
  
  * once if the value is not empty and is not an array
  * zero times if the value is empty. The values 0, false, null and
  undefined count as empty.
  * as many times as there are elements in the array if the value is
  an array

The ``{{.}}`` name represents the value or the current item in the
  array.
  
  The "tag" argument can be used to specify a HTML tag to repeat when
  there are two or more items in the array. Mistigri looks for the
  tag in the text that comes immediately before the block, stopping at
  the next enclosing block. It stops at the first Mistigri tag for the 
  close tag. For example, to insert a new table row for each person 
  use:
  
~~~
<table>
   <tr>
      <td>{{#person tag="TR"}}{{first_name}}</td>
      <td>{{last_name}}{{/person}}</td>
   </tr>
</table>
~~~

  If name is associated with a function returning a string, the
  return value of this function is inserted as text. If it returns 
  anything else, the returned value is used to decide how many times 
  to insert the text between tags.
  
  If the array item or the value associated with name is an object
  then its members are added to the model. A "suffix" argument can be
  provided to rename these members.
  
~~~
{{^name}}...{{/name}}
~~~

  Inverts the condition:
  
  * the text is inserted zero times if the value is not empty
  * the text is inserted once if the value is empty

When the value is a function the special argument $invertBlock is
  set in the arguments object to indicate whether the block is inverted 
  or not.

~~~
{{>path}}
~~~

  Includes another template at the specified location.
  This feature requires a callback function to be called at the end of the
  rendering.
  
  The path cannot contain spaces. But it can refer to an argument which is
  allowed to contain spaces, for example:

~~~
{{>file file = "C:\\Program Files\\MyApplication\\template.mi"}}
~~~

  All the arguments make up the model of the included template.
  
  Templates are cached so they don't need to be loaded again and again,
  and the argument ``render="no"`` indicates that the template should
  only be preloaded and not rendered out.
  
~~~
{{! comment }}
~~~

  Does not insert anything.
  
  The comment cannot contain ``{{`` or ``}}``.

Configuration options
---

  __openBrace__ : _string_
  
  The characters that open a Mistigri tag. The default is ``{{``.
  
  __closeBrace__ : _string_
  
  The characters that close a Mistigri tag. The default is ``}}``.
  
  __placeholder__ : _string_
  
  The text to insert as placeholder when there is no appropriate 
  value to insert. The default is "N/A".
  
  __escapeFunction__ : _function(string) &#x2192; string_
  
  The escape function to use when the tag does not start with 
  ``&``. The default is to escape HTML characters (requires DOM).
  
  __methodCall__ : _boolean_
  
  Controls the binding of "this" in function calls, which allows 
  object methods to work as expected.
  
  For security reasons the default is _false_.

  __reader__ : _function(string) &#x2192; Promise of string_
  
  A function that reads a template and returns it wrapped in a
  promise.
  
  The default is a function that does an Ajax request when provided
  an URI (requires DOM).
  
  There is also a reader generator to use for testing purposes which
  returns a reader when fed an object containing templates. This is
  an example of use:

~~~
mistigri.process(
  "Mistigri {{>include}}", 
  {}, 
  {reader: mistigri.feed({include: "catface &#931;:{"})}
);
~~~

Special names added to the model
---

  __$item__
  
  The value or the current item in the array inside a block.
  
  Always refers to the current block.
  <commit_msg>The README still had a reference to a callback function<commit_after># Mistigri.js
JavaScript template engine inspired by Mustache.

It could be called an antinome of Handlebars, extending Mustache 
without the addition of new keywords.
The main new concept is that of arguments.

[https://github.com/jido/mistigri.js/Examples]{Examples}

Supported features
-------

~~~
{{name}}
~~~

  Inserts the value associated with name in the model.
  
  When the value is null or undefined the default value is inserted. 
  If none is specified then a generic placeholder text is inserted.
  
  Nested values are allowed, for example "person\.name".
  
  If the name is associated with a function then this function is
  called to provide a value. See also Configuration Options.
  
~~~
{{name argument = value}}
~~~

  Provides an argument with a value.
  
  The "default" argument is used when the value associated with name
  is null or undefined.
  
  For boolean values the arguments "yes" and "no" provide the text to 
  insert.
  
  For function values the arguments are passed as an object.
  
  The value provided for the argument can be a number, a string within
  quotes or a name in the model.
  
~~~
{{&name}}
~~~

  Same as ``{{name}}`` except the value is not escaped.
  
  The default escape function is designed to safely insert text in an
  HTML document.
  
~~~
{{#name}}...{{/name}}
~~~

  Inserts the text between the tags depending on the value associated
  with name:
  
  * once if the value is not empty and is not an array
  * zero times if the value is empty. The values 0, false, null and
  undefined count as empty.
  * as many times as there are elements in the array if the value is
  an array

The ``{{.}}`` name represents the value or the current item in the
  array.
  
  The "tag" argument can be used to specify a HTML tag to repeat when
  there are two or more items in the array. Mistigri looks for the
  tag in the text that comes immediately before the block, stopping at
  the next enclosing block. It stops at the first Mistigri tag for the 
  close tag. For example, to insert a new table row for each person 
  use:
  
~~~
<table>
   <tr>
      <td>{{#person tag="TR"}}{{first_name}}</td>
      <td>{{last_name}}{{/person}}</td>
   </tr>
</table>
~~~

  If name is associated with a function returning a string, the
  return value of this function is inserted as text. If it returns a promise then the text is inserted at the end of the rendering. If it returns 
  anything else, the returned value is used to decide how many times 
  to insert the text between tags.
  
  If the array item or the value associated with name is an object
  then its members are added to the model. A "suffix" argument can be
  provided to rename these members.
  
~~~
{{^name}}...{{/name}}
~~~

  Inverts the condition:
  
  * the text is inserted zero times if the value is not empty
  * the text is inserted once if the value is empty

When the value is a function the special argument $invertBlock is
  set in the arguments object to indicate whether the block is inverted 
  or not.

~~~
{{>path}}
~~~

  Includes another template at the specified location.
  This feature relies on promises to defer the output until all the data is ready. However, the returned promise can be immediately converted to text if you want to see the result before the insertion of other templates. 
  
  The path cannot contain spaces. But it can refer to an argument which is
  allowed to contain spaces, for example:

~~~
{{>file file = "C:\\Program Files\\MyApplication\\template.mi"}}
~~~

  All the arguments make up the model of the included template.
  
  Templates are cached so they don't need to be loaded again and again,
  and the argument ``render="no"`` indicates that the template should
  only be preloaded and not rendered out.
  
~~~
{{! comment }}
~~~

  Does not insert anything.
  
  The comment cannot contain ``{{`` or ``}}``.

Configuration options
---

  __openBrace__ : _string_
  
  The characters that open a Mistigri tag. The default is ``{{``.
  
  __closeBrace__ : _string_
  
  The characters that close a Mistigri tag. The default is ``}}``.
  
  __placeholder__ : _string_
  
  The text to insert as placeholder when there is no appropriate 
  value to insert. The default is "N/A".
  
  __escapeFunction__ : _function(string) &#x2192; string_
  
  The escape function to use when the tag does not start with 
  ``&``. The default is to escape HTML characters (requires DOM).
  
  __methodCall__ : _boolean_
  
  Controls the binding of "this" in function calls, which allows 
  object methods to work as expected.
  
  For security reasons the default is _false_.

  __reader__ : _function(string) &#x2192; Promise of string_
  
  A function that reads a template and returns it wrapped in a
  promise.
  
  The default is a function that does an Ajax request when provided
  an URI (requires DOM).
  
  There is also a reader generator for testing purposes which
  returns a reader when fed an object containing templates. This is
  an example of use:

~~~
mistigri.process(
  "Mistigri {{>include}}", 
  {}, 
  {reader: mistigri.feed({include: "catface &#931;:{"})}
);
~~~

Special names added to the model
---

  __$item__
  
  The value or the current item in the array inside a block.
  
  Always refers to the current block.
  
{'fraction_non_alphanumeric': 0.07462400613085544, 'fraction_numerical': 0.002299070792221477, 'mean_word_length': 3.240454914703493, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 1, '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': '274987', 'n_tokens_mistral': 2989, 'n_tokens_neox': 2853, 'n_words': 1531}