# gyb
A pip-installable version of Apple's gyb python-based templating tool. To install:
pip install gyb
For help (assuming that the pip installed binaries path is in your `PATH`):
gyb -h
To use:
gyb file.ext.gyb -o file.ext
For details, see this great [blog post](https://nshipster.com/swift-gyb/).
## Summary (from `gyb -h`)
A GYB template consists of the following elements:
- Literal text which is inserted directly into the output
- `%%` or `$$` in literal text, which insert literal '%' and '$' symbols respectively.
- Substitutions of the form `${<python-expression>}`. The Python expression is converted to a string and the result is inserted into the output.
- Python code delimited by `%{...}%`. Typically used to inject definitions (functions, classes, variable bindings) into the evaluation context of the template. Common indentation is stripped, so you can add as much indentation to the beginning of this code as you like
- Lines beginning with optional whitespace followed by a single '%' and Python code. %-lines allow you to nest other constructs inside them. To close a level of nesting, use the `%end` construct.
- Lines beginning with optional whitespace and followed by a single '%' and the token "end", which close open constructs in %-lines.
## Some examples
Create implementations of all the math operators:
```
% for op,f in zip('+-*/', 'add sub mul div'.split()):
public static func ${op} (lhs:Self, rhs:Self ) -> Self { return lhs.${f}( rhs) }
% end
```
Define a variable:
```
%{ types = ('Float', 'Double') }%
```
A pip-installable version of Apple's gyb python-based templating tool. To install:
pip install gyb
For help (assuming that the pip installed binaries path is in your `PATH`):
gyb -h
To use:
gyb file.ext.gyb -o file.ext
For details, see this great [blog post](https://nshipster.com/swift-gyb/).
## Summary (from `gyb -h`)
A GYB template consists of the following elements:
- Literal text which is inserted directly into the output
- `%%` or `$$` in literal text, which insert literal '%' and '$' symbols respectively.
- Substitutions of the form `${<python-expression>}`. The Python expression is converted to a string and the result is inserted into the output.
- Python code delimited by `%{...}%`. Typically used to inject definitions (functions, classes, variable bindings) into the evaluation context of the template. Common indentation is stripped, so you can add as much indentation to the beginning of this code as you like
- Lines beginning with optional whitespace followed by a single '%' and Python code. %-lines allow you to nest other constructs inside them. To close a level of nesting, use the `%end` construct.
- Lines beginning with optional whitespace and followed by a single '%' and the token "end", which close open constructs in %-lines.
## Some examples
Create implementations of all the math operators:
```
% for op,f in zip('+-*/', 'add sub mul div'.split()):
public static func ${op} (lhs:Self, rhs:Self ) -> Self { return lhs.${f}( rhs) }
% end
```
Define a variable:
```
%{ types = ('Float', 'Double') }%
```
Metadata
Release files for gyb 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gyb-1.0.2.tar.gz | 17.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gyb-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.1 kB
Release files / gyb-1.0.2.tar.gz
| Download URL | gyb-1.0.2.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f55c5a4c01c273a73a5908193dbe99e1c9f8a9b2c85ceccb85ee60035fc46eb3
|
|
BLAKE2b-256 checksum How to use checksums |
06b85f4f34b9865d63d1b90ae4d2cce12f0af6a1c443e2d172d77ec1d24aabca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/36.5.0.post20170921 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.2
|
Release files / gyb-1.0.2-py3-none-any.whl
| Download URL | gyb-1.0.2-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68554e0310c8dabd09ed58220745be628c061f5353238662fe50db8e8c309b4e
|
|
BLAKE2b-256 checksum How to use checksums |
356d7e8cdcbe5060c0aa893a1fa270ba7da544ab01f1fa61c550fd917c069125
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/36.5.0.post20170921 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.2
|