<NME> filters-strings.md
<BEF> # Filters

This is a list of filters that are added by StencilSwiftKit on top of the filters already provided by Stencil (which you can [find here](http://stencil.fuller.li/en/latest/builtins.html#built-in-filters)).

## Filter: `basename`

Get the last component of a path, essentially the filename (and extension).

| Input                  | Output         |
|------------------------|----------------|
| `test.jpg`             | `test.jpg`     |
| `some/folder/test.jpg` | `test.jpg`     |
| `file.txt.png`         | `file.txt.png` |

## Filter: `camelToSnakeCase`

Transforms text from camelCase to snake_case. The filter accepts an optional boolean parameter:

- **true** (default): Lowercase each component.
- **false**: Keep the casing for each component.

| Input                   | Output (`true`)         | Output (`false`)        |
|-------------------------|-------------------------|-------------------------|
| `SomeCapString`         | `some_cap_string`       | `Some_Cap_String`       |
| `someCapString`         | `some_cap_string`       | `some_Cap_String`       |
| `String_With_WoRds`     | `string_with_words`     | `String_With_Wo_Rds`    |
| `string_wiTH_WOrds`     | `st_ring_with_words`    | `string_wi_TH_W_Ords`   |
| `URLChooser`            | `url_chooser`           | `URL_Chooser`           |
| `PLEASE_STOP_SCREAMING` | `please_stop_screaming` | `PLEASE_STOP_SCREAMING` |

## Filter: `contains`

Checks if the string contains given substring - works the same as Swift's `String.contains`.

| Input             | Output  |
|-------------------|---------|
| `Hello` `el`      | `true`  |
| `Hi mates!` `yo`  | `false` |

## Filter: `dirname`

Remove the last component of a path, essentially returning the path without the filename (and extension).

| Input                  | Output        |
|------------------------|---------------|
| `test.jpg`             | ``            |
| `some/folder/test.jpg` | `some/folder` |
| `file.txt.png`         | ``            |

## Filter: `escapeReservedKeywords`

Checks if the given string matches a reserved Swift keyword. If it does, wrap the string in escape characters (backticks).

| Input   | Output       |
|---------|--------------|
| `hello` | `hello`      |
| `self`  | `` `self` `` |
| `Any`   | `` `Any` ``  |

## Filter: `hasPrefix`

Checks if the string has the given prefix - works the same as Swift's `String.hasPrefix`.

| Input             | Output  |
|-------------------|---------|
| `Hello` `Hi`      | `false` |
| `Hi mates!` `H`   | `true`  |

## Filter: `hasSuffix`

Checks if the string has the given suffix - works the same as Swift's `String.hasSuffix`.

| Input             | Output  |
|-------------------|---------|
| `Hello` `llo`     | `true`  |
| `Hi mates!` `?`   | `false` |

## Filter: `lowerFirstLetter`

Simply lowercases the first character, leaving the other characters untouched.

| Input           | Output          |
|-----------------|-----------------|
| `Hello`         | `hello`         |
| `PeopleChooser` | `peopleChooser` |
| `Hi There!`     | `hi There!`     |

## Filter: `lowerFirstWord`

Transforms an arbitrary string so that only the first "word" is lowercased.

- If the string starts with only one uppercase character, lowercase that first character.
- If the string starts with multiple uppercase character, lowercase those first characters up to the one before the last uppercase one, but only if the last one is followed by a lowercase character. This allows to support strings beginnng with an acronym, like `URL`.

| Input          | Output         |
|----------------|----------------|
| `PeoplePicker` | `peoplePicker` |
| `URLChooser`   | `urlChooser`   |

## Filter: `replace`

This filter receives at least 2 parameters: a search parameter and a replacement.
This filter has a couple of modes that you can specify using an optional mode argument:

- **normal** (default): Simple find and replace.
- **regex**: Enables the use of regular expressions in the search parameter.

| Input (search, replacement) | Output (`normal`) | Output (`regex`) |
|-----------------------------|-------------------|------------------|
| `Hello` (`l`, `k`)          | `Hekko`           | `Hekko`          |
| `Europe` (`e`, `a`)         | `Europa`          | `Europa`         |
| `Hey1World2!` (`\d`, ` `)   | `Hey1World2!`     | `Hey World !`    |

## Filter: `snakeToCamelCase`

Transforms a string in "snake_case" format into one in "camelCase" format, following the steps below:

- Separate the string in components using the `_` as separator.
- For each component, uppercase the first character and do not touch the other characters in the component.
- Join the components again into one string.

If the whole starting "snake_case" string only contained uppercase characters, then each component will be capitalized: uppercase the first character and lowercase the other characters.

|-----------------|-----------------|
| `hello`         | `Hello`         |
| `peopleChooser` | `PeopleChooser` |
| Input           | Output          |
|-----------------|-----------------|
| `hello`         | `Hello`         |
| `peopleChooser` | `PeopleChooser` |

<MSG> Update documentation;

<DFF> @@ -124,3 +124,50 @@ Note that even if very similar, this filter differs from the `capitalized` filte
 |-----------------|-----------------|
 | `hello`         | `Hello`         |
 | `peopleChooser` | `PeopleChooser` |
+
+## Filter: `lowerFirstLetter`
+
+Simply lowercases the first character, leaving the other characters untouched.
+
+| Input           | Output          |
+|-----------------|-----------------|
+| `Hello`         | `hello`         |
+| `PeopleChooser` | `peopleChooser` |
+| `Hi There!`     | `hi There!`     |
+
+## Filter: `contains`
+
+Checks if the string contains given substring - the same as `String.contains` in Swift works.
+
+| Input             | Output          |
+|-------------------|-----------------|
+| `Hello` `el`      | true            |
+| `Hi mates!` `yo`  | false           |
+
+## Filter: `hasPrefix`
+
+Checks if the string has the given prefix - the same as `String.hasPrefix` in Swift works.
+
+| Input             | Output          |
+|-------------------|-----------------|
+| `Hello` `Hi`      | false           |
+| `Hi mates!` `H`   | true            |
+
+## Filter: `hasSuffix`
+
+Checks if the string has the given suffix - the same as `String.hasSuffix` in Swift works.
+
+| Input             | Output          |
+|-------------------|-----------------|
+| `Hello` `llo`     | true            |
+| `Hi mates!` `?`   | false           |
+
+## Filter: `replace`
+
+Replaces the given substring with the given replacement in the source string.
+The same as `Swift.replace` works.
+
+| Input             | Output          |
+|-------------------|-----------------|
+| `Hello` `l` `k`   | `Hekko`         |
+| `Europe` `e` `a`  | `Europa`        |

{'commit': 'diff --git a/Documentation/filters-strings.md b/Documentation/filters-strings.md\nindex 948d661..6d03b08 100644\n--- a/Documentation/filters-strings.md\n+++ b/Documentation/filters-strings.md\n@@ -124,3 +124,50 @@ Note that even if very similar, this filter differs from the `capitalized` filte\n |-----------------|-----------------|\n | `hello`         | `Hello`         |\n | `peopleChooser` | `PeopleChooser` |\n+\n+## Filter: `lowerFirstLetter`\n+\n+Simply lowercases the first character, leaving the other characters untouched.\n+\n+| Input           | Output          |\n+|-----------------|-----------------|\n+| `Hello`         | `hello`         |\n+| `PeopleChooser` | `peopleChooser` |\n+| `Hi There!`     | `hi There!`     |\n+\n+## Filter: `contains`\n+\n+Checks if the string contains given substring - the same as `String.contains` in Swift works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `el`      | true            |\n+| `Hi mates!` `yo`  | false           |\n+\n+## Filter: `hasPrefix`\n+\n+Checks if the string has the given prefix - the same as `String.hasPrefix` in Swift works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `Hi`      | false           |\n+| `Hi mates!` `H`   | true            |\n+\n+## Filter: `hasSuffix`\n+\n+Checks if the string has the given suffix - the same as `String.hasSuffix` in Swift works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `llo`     | true            |\n+| `Hi mates!` `?`   | false           |\n+\n+## Filter: `replace`\n+\n+Replaces the given substring with the given replacement in the source string.\n+The same as `Swift.replace` works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `l` `k`   | `Hekko`         |\n+| `Europe` `e` `a`  | `Europa`        |\n', 'commit_subject': 'Update documentation;', 'repo_name': 'SwiftGen/StencilSwiftKit', 'committer': {'name': 'Anton Domashnev', 'email': '7d27aede6fd693080a0a76d9dbfca254fd53b430@gmail.com', 'time_sec': '1501354941', 'tz_offset': '120', 'date': {'seconds': '1501354941'}}, 'commit_tree': 'b1f9bb00e1c691c81f0eb6b6f74f53b4632166f4', 'commit_message': 'Update documentation;\n', 'language_name': 'Shell', 'license': 'mit', 'hunks': '@@ -124,3 +124,50 @@ Note that even if very similar, this filter differs from the `capitalized` filte\n |-----------------|-----------------|\n | `hello`         | `Hello`         |\n | `peopleChooser` | `PeopleChooser` |\n+\n+## Filter: `lowerFirstLetter`\n+\n+Simply lowercases the first character, leaving the other characters untouched.\n+\n+| Input           | Output          |\n+|-----------------|-----------------|\n+| `Hello`         | `hello`         |\n+| `PeopleChooser` | `peopleChooser` |\n+| `Hi There!`     | `hi There!`     |\n+\n+## Filter: `contains`\n+\n+Checks if the string contains given substring - the same as `String.contains` in Swift works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `el`      | true            |\n+| `Hi mates!` `yo`  | false           |\n+\n+## Filter: `hasPrefix`\n+\n+Checks if the string has the given prefix - the same as `String.hasPrefix` in Swift works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `Hi`      | false           |\n+| `Hi mates!` `H`   | true            |\n+\n+## Filter: `hasSuffix`\n+\n+Checks if the string has the given suffix - the same as `String.hasSuffix` in Swift works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `llo`     | true            |\n+| `Hi mates!` `?`   | false           |\n+\n+## Filter: `replace`\n+\n+Replaces the given substring with the given replacement in the source string.\n+The same as `Swift.replace` works.\n+\n+| Input             | Output          |\n+|-------------------|-----------------|\n+| `Hello` `l` `k`   | `Hekko`         |\n+| `Europe` `e` `a`  | `Europa`        |\n', 'addition_count': 47, 'deletion_count': 0, 'src_file': 'a/Documentation/filters-strings.md', 'tgt_file': 'b/Documentation/filters-strings.md', 'file_extension': '.md', 'before_file': '# Filters\n\nThis is a list of filters that are added by StencilSwiftKit on top of the filters already provided by Stencil (which you can [find here](http://stencil.fuller.li/en/latest/builtins.html#built-in-filters)).\n\n## Filter: `basename`\n\nGet the last component of a path, essentially the filename (and extension).\n\n| Input                  | Output         |\n|------------------------|----------------|\n| `test.jpg`             | `test.jpg`     |\n| `some/folder/test.jpg` | `test.jpg`     |\n| `file.txt.png`         | `file.txt.png` |\n\n## Filter: `camelToSnakeCase`\n\nTransforms text from camelCase to snake_case. The filter accepts an optional boolean parameter:\n\n- **true** (default): Lowercase each component.\n- **false**: Keep the casing for each component.\n\n| Input                   | Output (`true`)         | Output (`false`)        |\n|-------------------------|-------------------------|-------------------------|\n| `SomeCapString`         | `some_cap_string`       | `Some_Cap_String`       |\n| `someCapString`         | `some_cap_string`       | `some_Cap_String`       |\n| `String_With_WoRds`     | `string_with_words`     | `String_With_Wo_Rds`    |\n| `string_wiTH_WOrds`     | `st_ring_with_words`    | `string_wi_TH_W_Ords`   |\n| `URLChooser`            | `url_chooser`           | `URL_Chooser`           |\n| `PLEASE_STOP_SCREAMING` | `please_stop_screaming` | `PLEASE_STOP_SCREAMING` |\n\n## Filter: `contains`\n\nChecks if the string contains given substring - works the same as Swift\'s `String.contains`.\n\n| Input             | Output  |\n|-------------------|---------|\n| `Hello` `el`      | `true`  |\n| `Hi mates!` `yo`  | `false` |\n\n## Filter: `dirname`\n\nRemove the last component of a path, essentially returning the path without the filename (and extension).\n\n| Input                  | Output        |\n|------------------------|---------------|\n| `test.jpg`             | ``            |\n| `some/folder/test.jpg` | `some/folder` |\n| `file.txt.png`         | ``            |\n\n## Filter: `escapeReservedKeywords`\n\nChecks if the given string matches a reserved Swift keyword. If it does, wrap the string in escape characters (backticks).\n\n| Input   | Output       |\n|---------|--------------|\n| `hello` | `hello`      |\n| `self`  | `` `self` `` |\n| `Any`   | `` `Any` ``  |\n\n## Filter: `hasPrefix`\n\nChecks if the string has the given prefix - works the same as Swift\'s `String.hasPrefix`.\n\n| Input             | Output  |\n|-------------------|---------|\n| `Hello` `Hi`      | `false` |\n| `Hi mates!` `H`   | `true`  |\n\n## Filter: `hasSuffix`\n\nChecks if the string has the given suffix - works the same as Swift\'s `String.hasSuffix`.\n\n| Input             | Output  |\n|-------------------|---------|\n| `Hello` `llo`     | `true`  |\n| `Hi mates!` `?`   | `false` |\n\n## Filter: `lowerFirstLetter`\n\nSimply lowercases the first character, leaving the other characters untouched.\n\n| Input           | Output          |\n|-----------------|-----------------|\n| `Hello`         | `hello`         |\n| `PeopleChooser` | `peopleChooser` |\n| `Hi There!`     | `hi There!`     |\n\n## Filter: `lowerFirstWord`\n\nTransforms an arbitrary string so that only the first "word" is lowercased.\n\n- If the string starts with only one uppercase character, lowercase that first character.\n- If the string starts with multiple uppercase character, lowercase those first characters up to the one before the last uppercase one, but only if the last one is followed by a lowercase character. This allows to support strings beginnng with an acronym, like `URL`.\n\n| Input          | Output         |\n|----------------|----------------|\n| `PeoplePicker` | `peoplePicker` |\n| `URLChooser`   | `urlChooser`   |\n\n## Filter: `replace`\n\nThis filter receives at least 2 parameters: a search parameter and a replacement.\nThis filter has a couple of modes that you can specify using an optional mode argument:\n\n- **normal** (default): Simple find and replace.\n- **regex**: Enables the use of regular expressions in the search parameter.\n\n| Input (search, replacement) | Output (`normal`) | Output (`regex`) |\n|-----------------------------|-------------------|------------------|\n| `Hello` (`l`, `k`)          | `Hekko`           | `Hekko`          |\n| `Europe` (`e`, `a`)         | `Europa`          | `Europa`         |\n| `Hey1World2!` (`\\d`, ` `)   | `Hey1World2!`     | `Hey World !`    |\n\n## Filter: `snakeToCamelCase`\n\nTransforms a string in "snake_case" format into one in "camelCase" format, following the steps below:\n\n- Separate the string in components using the `_` as separator.\n- For each component, uppercase the first character and do not touch the other characters in the component.\n- Join the components again into one string.\n\nIf the whole starting "snake_case" string only contained uppercase characters, then each component will be capitalized: uppercase the first character and lowercase the other characters.\n\n|-----------------|-----------------|\n| `hello`         | `Hello`         |\n| `peopleChooser` | `PeopleChooser` |\n| Input           | Output          |\n|-----------------|-----------------|\n| `hello`         | `Hello`         |\n| `peopleChooser` | `PeopleChooser` |\n', 'message': 'Update documentation;\n', 'author_name': 'Anton Domashnev', 'lang': 'md'}