https://github.com/alephao/stencil-cli
Render a Stencil template by using a JSON or Yaml data source
https://github.com/alephao/stencil-cli
cli codegen stencil-template swift
Last synced: about 1 year ago
JSON representation
Render a Stencil template by using a JSON or Yaml data source
- Host: GitHub
- URL: https://github.com/alephao/stencil-cli
- Owner: alephao
- License: mit
- Created: 2019-09-27T11:47:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T05:16:43.000Z (about 6 years ago)
- Last Synced: 2025-04-16T13:55:23.121Z (about 1 year ago)
- Topics: cli, codegen, stencil-template, swift
- Language: Swift
- Homepage:
- Size: 34.2 KB
- Stars: 17
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stencil CLI
A CLI tool to render [Stencil](https://github.com/stencilproject/Stencil) templates by using a JSON or Yaml data source.
Tags and filters from [StencilSwiftKit](https://github.com/SwiftGen/StencilSwiftKit) are supported.
## Installing
### Using Homebrew
```
brew install alephao/formulae/stencil
```
### Using [Mint](https://github.com/yonaskolb/mint):
```
$ mint install alephao/Stencil-CLI
```
### Using Make
```
$ git clone https://github.com/alephao/Stencil-CLI.git
$ cd stencil-cli
$ make install
```
## Usage
```
$ stencil render -t path/to/template.stencil -d path/to/datasource.yaml -o path/to/output
```
## Example
Given the stencil template
```
extension Color {
{% for color in colors %}
public static let {{ color.name }} = Color(hex: 0x{{ color.hex }})
{% endfor %}
}
```
And the yaml file
```yaml
colors:
- name: color1
hex: '111111'
- name: color2
hex: '222222'
- name: color3
hex: '333333'
- name: color4
hex: '444444'
```
stencil-cli generates
```swift
extension Color {
public static let color1 = Color(hex: 0x111111)
public static let color2 = Color(hex: 0x222222)
public static let color3 = Color(hex: 0x333333)
public static let color4 = Color(hex: 0x444444)
}
```
## Attributions
This tool is powered by:
* [Stencil](https://github.com/stencilproject/Stencil)
* [SwiftStencilKit](https://github.com/SwiftGen/StencilSwiftKit)
* [SwiftyJSON](https://github.com/SwiftyJSON/SwiftyJSON)
* [Yams](https://github.com/jpsim/Yams)
* [swift-argument-parser](https://github.com/apple/swift-argument-parser)
* Tested using [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing)
## License
Stencil CLI is available under the MIT license. See LICENSE for more information.