$ cat TestResources/simple1/a.txt.gysb
Hello 100%%
%{
let y = 10
let x = 42
func succ(_ a: Int) -> Int {
return a + 1
}
}%
I can assure you that ${x} < ${succ(x)}
% if y > 7 {
% for _ in 0..<3 {
y is greater than seven!
% }
% } else {
y is less than or equal to seven
% }
The End.
$ swift run gysb Examples/simple1/a.txt.gysb
Hello 100%
I can assure you that 42 < 43
y is greater than seven!
y is greater than seven!
y is greater than seven!
The End.
$ swift run gysb --help
Usage: .build/x86_64-apple-macosx10.10/debug/gysb [mode] [flags] paths...
# mode
--help: print help
--parse: print AST
--compile: print compiled Swift
--render: render template (default)
# flags
--write: write output on same directory (extension removed)
--source-dirs: paths means directory and search *.gysb (automatically enable `--write`)
syntax
%%: escaped %
$: escaped $
%{ <swift-code> }%: code block
% <swift-code> <newline>: code line
${ <swift-code> }: code substitution
gysb.json
You can use more useful feature of gysb by using gysb.json.
gysb command search gysb.json for each gysb template files within same or ancestor directory.
gysb.json features
local library script inclusion. See example in Examples/simple_include.
external library via SwiftPM package. See example in Examples/yaml.
install
There are some install approachs.
install from homebrew
build yourself and set path
homebrew
$ brew install omochi/taps/gysb
build yourself
Checkout repository.
$ git clone https://github.com/omochi/gysb.git
$ cd gysb
gysb
gysb is Generate Your Swifty Boilerplate.
Swift implementation of swift/gyb
example
other examples
See
Examples
andTests
.docs
command line help
syntax
%%
: escaped%
$
: escaped$
%{ <swift-code> }%
: code block% <swift-code> <newline>
: code line${ <swift-code> }
: code substitutiongysb.json
You can use more useful feature of gysb by using
gysb.json
. gysb command searchgysb.json
for each gysb template files within same or ancestor directory.gysb.json features
Examples/simple_include
.Examples/yaml
.install
There are some install approachs.
homebrew
build yourself
Checkout repository.
Build.
Get path.
Set path.
development
This repository is maintained by SwiftPM.
Use xcodeproj and work with it.