Skip to content

Commit a443c9a

Browse files
committed
backend rework
1 parent ae1b2bf commit a443c9a

43 files changed

Lines changed: 1590 additions & 1102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/templates/README.template.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Getting Started](#getting-started)
1212
- [Usage](#usage)
1313
- [String Functions](#string-functions)
14+
- [Math Functions](#math-functions)
1415
- [Container Functions](#container-functions)
1516
- [Parser Functions](#parser-functions)
1617
- [Advanced Functions](#advanced-functions)
@@ -41,7 +42,7 @@ Goplater uses Go's [builtin templating library](https://pkg.go.dev/text/template
4142
**Example:**
4243

4344
```
44-
File Content: $​{​{​{ read "./myfile.txt" }​}​}
45+
File Content: +​{​{​{ read "./myfile.txt" }​}​}
4546
```
4647

4748
As you saw in the example above `read` is used for reading and output file contents.
@@ -58,18 +59,16 @@ where relative paths are relative to the invoker.
5859
read "path"
5960
```
6061

61-
##### `readOpts`
62+
#### `readArgs`
6263

63-
Same as [`read`](#read) but with another parameter for additional arguments:
64-
65-
| Short | Long | Type | Note |
66-
| ----- | ------------- | ------ | --------------------------- |
67-
| `-r` | `--recursive` | `bool` | tries templating read files |
64+
Same as [`read`], but allows to supply additional arguments to the file for further processing.
6865

6966
```
70-
read "path" "--flag1" "--flag2"
67+
read "path" arg1 arg2 arg3
7168
```
7269

70+
Arguments are accessible in under `.args` with `{{{ index .args 0 }}}`.
71+
7372
#### `fetch`
7473

7574
Performs a get http request to the specified url.
@@ -242,6 +241,28 @@ Replaces substring via regex in string.
242241
regexReplace "string" "replace_regex" "replace_with"
243242
```
244243

244+
### Math Functions
245+
246+
#### `add`
247+
248+
Adds two numbers together.
249+
250+
#### `sub`
251+
252+
Subtraction for two numbers.
253+
254+
#### `mult`
255+
256+
Multiplies two numbers.
257+
258+
#### `divd`
259+
260+
Divides a through b.
261+
262+
#### `mod`
263+
264+
Performs a modulo b.
265+
245266
### Conversion Functions
246267

247268
Functions for converting types.
@@ -274,6 +295,10 @@ The following are functions for slices and maps.
274295

275296
Returns wether map or slice has key.
276297

298+
#### `includes`
299+
300+
Returns wether map or slice includes value.
301+
277302
#### `delete`
278303

279304
Deletes an entry from a map or slice.
@@ -467,7 +492,7 @@ Sets return output slice directly with **one slice**.
467492
returnOutputs slice
468493
```
469494

470-
##### `outputsGet`
495+
##### `getOutputs`
471496

472497
Returns the whole output slice.
473498

@@ -479,7 +504,7 @@ Calls a global function by its name (without passing any arguments).
479504
funcCall "name"
480505
```
481506

482-
Returns list of [`return`](#return) outputs in order of index.
507+
Returns list of [`return`](#return) outputs in order of index, or if applicable only a single output.
483508

484509
#### `funcCallArgs`
485510

go.mod

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,18 @@ go 1.26.0
44

55
require (
66
github.com/PuerkitoBio/goquery v1.11.0
7-
github.com/jessevdk/go-flags v1.6.1
87
github.com/spf13/cobra v1.10.1
98
)
109

1110
require (
1211
github.com/codeshelldev/gotl/pkg/jsonutils v0.0.2
13-
github.com/codeshelldev/gotl/pkg/templating v0.0.16
1412
go.yaml.in/yaml/v4 v4.0.0-rc.4
1513
)
1614

17-
require github.com/codeshelldev/gotl/pkg/stringutils v0.0.8 // indirect
18-
1915
require (
2016
github.com/andybalholm/cascadia v1.3.3 // indirect
2117
github.com/google/uuid v1.6.0
2218
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2319
github.com/spf13/pflag v1.0.9 // indirect
2420
golang.org/x/net v0.47.0 // indirect
25-
golang.org/x/sys v0.38.0 // indirect
2621
)

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@ github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kk
44
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
55
github.com/codeshelldev/gotl/pkg/jsonutils v0.0.2 h1:ERsjkaWVrsyUZoEunCEeNYDXhuaIvoSetB8e/zI4Tqo=
66
github.com/codeshelldev/gotl/pkg/jsonutils v0.0.2/go.mod h1:oxgKaAoMu6iYVHfgR7AhkK22xbYx4K0KCkyVEfYVoWs=
7-
github.com/codeshelldev/gotl/pkg/stringutils v0.0.8 h1:VKIuEYLJARDmHyhAbcMy1TsdxPdzsKlbQvgr1G4QE7s=
8-
github.com/codeshelldev/gotl/pkg/stringutils v0.0.8/go.mod h1:892bcYDpOf0sTpXtABQ3m+9MACpWHCVpN3f/mcPr7qo=
9-
github.com/codeshelldev/gotl/pkg/templating v0.0.16 h1:0dl/NEApCtlm4kyEscQPknx4DwUtl1bsgl3Iyv6jPkM=
10-
github.com/codeshelldev/gotl/pkg/templating v0.0.16/go.mod h1:MHM4ouEsLNKXRYO+fS9qqpS1SFlL4Z6Q/0kxtS+auLk=
117
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
128
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
139
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
1410
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1511
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
1612
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
17-
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
18-
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
1913
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
2014
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
2115
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
@@ -64,8 +58,6 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6458
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
6559
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
6660
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
67-
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
68-
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
6961
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
7062
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
7163
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

internals/template/context/context.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package context
22

3+
import "github.com/codeshelldev/goplater/pkg/templating"
4+
35
type TemplateOptions struct {
46
Output string
57
Source string
@@ -20,6 +22,8 @@ type TemplateContext struct {
2022
Options TemplateOptions
2123
}
2224

25+
const TemplateContextKey templating.ContextKey = "templateContext"
26+
2327
func New() TemplateContext {
2428
return TemplateContext{ Options: TemplateOptions{ } }
2529
}

internals/template/funcs/base64.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

internals/template/funcs/container.go

Lines changed: 0 additions & 139 deletions
This file was deleted.

internals/template/funcs/conversion.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)