{"id":20259782,"url":"https://github.com/swiftgen/stencilswiftkit","last_synced_at":"2025-04-05T02:11:51.563Z","repository":{"id":41506642,"uuid":"77799742","full_name":"SwiftGen/StencilSwiftKit","owner":"SwiftGen","description":"A framework bringing additional nodes \u0026 filters to Stencil dedicated to Swift code generation","archived":false,"fork":false,"pushed_at":"2023-03-17T06:01:28.000Z","size":30419,"stargazers_count":299,"open_issues_count":13,"forks_count":58,"subscribers_count":10,"default_branch":"stable","last_synced_at":"2025-03-29T01:13:58.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwiftGen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-01-01T22:40:30.000Z","updated_at":"2025-03-24T03:26:53.000Z","dependencies_parsed_at":"2024-01-19T10:17:17.692Z","dependency_job_id":"ccd41cae-99b4-40b1-9115-2e10fd7b9851","html_url":"https://github.com/SwiftGen/StencilSwiftKit","commit_stats":{"total_commits":437,"total_committers":17,"mean_commits":"25.705882352941178","dds":"0.45995423340961095","last_synced_commit":"fb6a88bac60b088a9f8b61bbc70eacecb2100b59"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftGen%2FStencilSwiftKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftGen%2FStencilSwiftKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftGen%2FStencilSwiftKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftGen%2FStencilSwiftKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftGen","download_url":"https://codeload.github.com/SwiftGen/StencilSwiftKit/tar.gz/refs/heads/stable","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T11:16:34.864Z","updated_at":"2025-04-05T02:11:51.533Z","avatar_url":"https://github.com/SwiftGen.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StencilSwiftKit\n\n[![CircleCI](https://circleci.com/gh/SwiftGen/StencilSwiftKit/tree/stable.svg?style=svg)](https://circleci.com/gh/SwiftGen/StencilSwiftKit/tree/stable)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/StencilSwiftKit.svg)](https://img.shields.io/cocoapods/v/StencilSwiftKit.svg)\n[![Platform](https://img.shields.io/cocoapods/p/StencilSwiftKit.svg?style=flat)](http://cocoadocs.org/docsets/StencilSwiftKit)\n![Swift 5.0](https://img.shields.io/badge/Swift-5.0-orange.svg)\n\n`StencilSwiftKit` is a framework bringing additional [Stencil](https://github.com/stencilproject/Stencil) nodes \u0026 filters dedicated to Swift code generation.\n\n## Tags\n\n* [Macro](Documentation/tag-macro.md) \u0026 [Call](Documentation/tag-call.md)\n  * `{% macro \u003cName\u003e \u003cParams\u003e %}…{% endmacro %}`\n  * Defines a macro that will be replaced by the nodes inside of this block later when called\n  * `{% call \u003cName\u003e \u003cArgs\u003e %}`\n  * Calls a previously defined macro, passing it some arguments\n* [Set](Documentation/tag-set.md)\n  * `{% set \u003cName\u003e %}…{% endset %}`\n  * Renders the nodes inside this block immediately, and stores the result in the `\u003cName\u003e`  variable of the current context.\n* [Import](Documentation/tag-import.md)\n  * `{% import \"common.stencil\" %}`\n  * Imports any macro \u0026 set definitions from `common.stencil` into the current context.\n* [Map](Documentation/tag-map.md)\n  * `{% map \u003cVariable\u003e into \u003cName\u003e using \u003cItemName\u003e %}…{% endmap %}`\n  * Apply a `map` operator to an array, and store the result into a new array variable `\u003cName\u003e` in the current context.\n  * Inside the map loop, a `maploop` special variable is available (akin to the `forloop` variable in `for` nodes). It exposes `maploop.counter`, `maploop.first`, `maploop.last` and `maploop.item`.\n\n## Filters\n\n* [String filters](Documentation/filters-strings.md):\n  * `basename`: Get the filename from a path.\n  * `camelToSnakeCase`: Transforms text from camelCase to snake_case. By default it converts to lower case, unless a single optional argument is set to \"false\", \"no\" or \"0\".\n  * `contains`: Check if a string contains a specific substring.\n  * `dirname`: Get the path to the parent folder from a path.\n  * `escapeReservedKeywords`: Escape keywords reserved in the Swift language, by wrapping them inside backticks so that the can be used as regular escape keywords in Swift code.\n  * `hasPrefix` / `hasSuffix`: Check if a string starts/ends with a specific substring.\n  * `lowerFirstLetter`: Lowercases only the first letter of a string.\n  * `lowerFirstWord`: Lowercases only the first word of a string.\n  * `replace`: Replaces instances of a substring with a new string.\n  * `snakeToCamelCase`: Transforms text from snake_case to camelCase. By default it keeps leading underscores, unless a single optional argument is set to \"true\", \"yes\" or \"1\".\n  * `swiftIdentifier`: Transforms an arbitrary string into a valid Swift identifier (using only valid characters for a Swift identifier as defined in the Swift language reference). In \"pretty\" mode, it will also apply the snakeToCamelCase filter afterwards, and other manipulations if needed for a \"prettier\" but still valid identifier.\n  * `upperFirstLetter`: Uppercases only the first character\n* [Number filters](Documentation/filters-numbers.md):\n  * `int255toFloat`\n  * `hexToInt`\n  * `percent`\n\n## Stencil.Extension \u0026 swiftStencilEnvironment\n\nThis framework also contains [helper methods for `Stencil.Extension` and `Stencil.Environment`](https://github.com/SwiftGen/StencilSwiftKit/blob/stable/Sources/StencilSwiftKit/Environment.swift), to easily register all the tags and filters listed above on an existing `Stencil.Extension`, as well as to easily get a `Stencil.Environment` preconfigured with both those tags \u0026 filters `Extension`.\n\n## Parameters\n\nThis framework contains an additional parser, meant to parse a list of parameters from the CLI. For example, using [Commander](https://github.com/kylef/Commander), if you receive a `[String]` from a `VariadicOption\u003cString\u003e`, you can use the parser to convert it into a structured dictionary. For example:\n\n```swift\n[\"foo=1\", \"bar=2\", \"baz.qux=hello\", \"baz.items=a\", \"baz.items=b\", \"something\"]\n```\n\nwill become\n\n```swift\n[\n  \"foo\": \"1\",\n  \"bar\": \"2\",\n  \"baz\": [\n    \"qux\": \"hello\",\n    \"items\": [\n      \"a\",\n      \"b\"\n    ]\n  ],\n  something: true\n]\n```\n\nFor easier use, you can use the `StencilContext.enrich(context:parameters:environment:)` function to add the following variables to a context:\n\n- `param`: the parsed parameters using the parser mentioned above.\n- `env`: a dictionary with all available environment variables (such as `PATH`).\n\n---\n\n# Licence\n\nThis code and tool is under the MIT Licence. See the `LICENCE` file in this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftgen%2Fstencilswiftkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftgen%2Fstencilswiftkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftgen%2Fstencilswiftkit/lists"}