@codeshelldev/goplater-darwin-arm64 0.0.0-stage → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +1742 -2
  3. package/bin/goplater +0 -0
  4. package/package.json +20 -5
package/README.md CHANGED
@@ -1,3 +1,1743 @@
1
- # Temporary Holding Version
1
+ <!--
2
+ # The following comment will appear as empty,
3
+ # because it has already been consumed and processed by Goplater
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ # imports
6
+
7
+
8
+
9
+
10
+ # library commands
11
+
12
+
13
+ -->
14
+
15
+ <p align="center">
16
+ <img width="256" height="256" alt="Goplater Logo" src="https://github.com/CodeShellDev/goplater/raw/refs/heads/main/logo/goplater.png">
17
+ </p>
18
+
19
+ <h1 align="center">Goplater</h1>
20
+
21
+ <div align="center">
22
+ <h3>Go templates with superpowers</h3>
23
+ Read files, call APIs, parse JSON, YAML and Markdown and write your own template functions<br>
24
+ </div>
25
+
26
+ <br>
27
+
28
+ <div align="center">
29
+ <a href="https://github.com/CodeShellDev/goplater/releases">
30
+ <img
31
+ src="https://img.shields.io/github/v/release/CodeShellDev/goplater?sort=semver&logo=github&label=Release"
32
+ alt="GitHub release">
33
+ </a>
34
+ <a href="https://github.com/CodeShellDev/goplater/stargazers">
35
+ <img
36
+ src="https://img.shields.io/github/stars/CodeShellDev/goplater?style=flat&logo=github&label=Stars"
37
+ alt="GitHub stars">
38
+ </a>
39
+ <a href="https://matrix.to/#/#codeshelldev.oss.goplater:matrix.org">
40
+ <img
41
+ alt="Matrix"
42
+ src="https://img.shields.io/matrix/codeshelldev.oss.goplater%3Amatrix.org?style=flat&color=blue&logo=matrix&label=Chat">
43
+ </a>
44
+ <a href="./LICENSE">
45
+ <img
46
+ src="https://img.shields.io/badge/License-MIT-green.svg"
47
+ alt="License: MIT">
48
+ </a>
49
+ </div>
50
+
51
+ ## See it in action
52
+
53
+ **`TEMPLATE.md`**
54
+
55
+ <!-- prettier-ignore -->
56
+ ```handlebars
57
+ +{{- $app := jsonDecode (readRaw "./package.json") -}}
58
+
59
+ # +{{ upper (index $app "name") }}
60
+
61
+ Version: +{{ index $app "version" }}
62
+
63
+ +{{ read "./install.md" }}
64
+ ```
65
+
66
+ ```bash
67
+ goplater template TEMPLATE.md -o README.md
68
+ ```
69
+
70
+ **`README.md`**
71
+
72
+ ```markdown
73
+ # MY-APP
74
+
75
+ Version: 1.2.3
76
+
77
+ ## Install
78
+
79
+ Run `npm install my-app`
80
+ ```
81
+
82
+ [This very README is generated with Goplater.](./.github/templates/README.template.md)
83
+
84
+
85
+ ## Contents
86
+
87
+ <!-- prettier-ignore -->
88
+ - [Why Goplater?](#why-goplater)
89
+ - [Getting Started](#getting-started)
90
+ - [Usage](#usage)
91
+ - [Standard Library](#standard-library)
92
+ - [fs](#fs)
93
+ - [outputto](#outputto)
94
+ - [container](#container)
95
+ - [conversion](#conversion)
96
+ - [globals](#globals)
97
+ - [import](#import)
98
+ - [return](#return)
99
+ - [debug](#debug)
100
+ - [base64](#base64)
101
+ - [hex](#hex)
102
+ - [hash](#hash)
103
+ - [html](#html)
104
+ - [http](#http)
105
+ - [json](#json)
106
+ - [markdown](#markdown)
107
+ - [formulas](#formulas)
108
+ - [operators](#operators)
109
+ - [regex](#regex)
110
+ - [strings](#strings)
111
+ - [yaml](#yaml)
112
+ - [Contributing](#contributing)
113
+ - [Support](#support)
114
+ - [License](#license)
115
+ - [Legal](#legal)
116
+
117
+ Need help? Come join our [Matrix Server](https://matrix.to/#/#codeshelldev.oss.goplater:matrix.org)!
118
+
119
+ ## Why Goplater?
120
+
121
+ - **Familiar.** It is Go's [`text/template`](https://pkg.go.dev/text/template) syntax. If you know it, you already know Goplater.
122
+ - **Batteries included.** Read and write files, fetch URLs, work with JSON, YAML, HTML and Markdown, run regex and string operations. See the [Standard Library](#standard-library).
123
+ - **Write your own functions, inside the template.** Define them with `define`, call them with `call`. Arguments and return values included.
124
+ - **Share and import functions.** Put your functions in a file, import them from disk or from a URL and reuse them everywhere.
125
+ - **Not just a CLI.** The engine behind it, `gplt-engine`, is a separate library you can embed in your own Go program.
126
+ - **Modular.** The library is split into independent modules. Load only what you need. Or let the CLI load them all.
127
+ - **Automated.** Use the [GitHub Action and Bot](https://github.com/CodeShellDev/goplater-action) to render templates and automate pull requests. See [Automation](#automate-with-github-actions).
128
+
129
+ ## Getting Started
130
+
131
+ Install with Go:
132
+
133
+ ```bash
134
+ go install github.com/codeshelldev/goplater@latest
135
+ ```
136
+
137
+ Or download the latest binary from the [Releases page](https://github.com/CodeShellDev/goplater/releases), make it executable with `chmod +x goplater` and run it.
138
+
139
+ Template your first file:
140
+
141
+ ```bash
142
+ goplater template examples/app-readme/template.md -o README.md
143
+ ```
144
+
145
+ This creates `README.md` in your current working directory.
146
+
147
+ ## Usage
148
+
149
+ ### Templating files
150
+
151
+
152
+
153
+ Goplater uses Go's [built-in templating library](https://pkg.go.dev/text/template), with actions written as `+{{ ... }}`. Files that already contain plain `{{ }}` (Helm charts, GitHub Actions, Mustache) pass through untouched.
154
+
155
+ <!-- prettier-ignore -->
156
+ ```handlebars
157
+ File Content: +{{ read "./myfile.txt" }}
158
+ ```
159
+
160
+
161
+
162
+ ### Whole folders
163
+
164
+ Point Goplater at a directory and it mirrors the structure into the output:
165
+
166
+ ```bash
167
+ goplater template ./examples -o ./out -r
168
+ ```
169
+
170
+ Useful flags:
171
+
172
+ | Flag | What it does |
173
+ | ------------------------ | ------------------------------------------------------------------ |
174
+ | `-o` | Output file or directory |
175
+ | `-s` | Source directory for `~/` paths |
176
+ | `-r` | Walk directories |
177
+ | `--match` | Only template files matching a regex |
178
+ | `--flatten` | Drop the directory structure |
179
+ | `--root` | Choose the root that output paths are relative to |
180
+ | `--allowed-outputs` | Limit where templates may write |
181
+ | `--trim-max-blank-lines` | Experimental: Remove blank lines left behind by non-output actions |
182
+ | `--dry-run` | Show what would be written, change nothing |
183
+ | `--ignore-errors` | Continue processing when errors occur |
184
+
185
+ ### Your own functions
186
+
187
+ Define a function in the template and call it:
188
+
189
+
190
+
191
+ <!-- prettier-ignore -->
192
+ ```handlebars
193
+ +{{ define "greet(name)" }}
194
+ +{{ returnNext (printf "Hello, %s!" .name) }}
195
+ +{{ end }}
196
+
197
+ +{{ call "greet" "Gopher" }}
198
+ ```
199
+
200
+
201
+
202
+ Output:
203
+
204
+ <!-- prettier-ignore -->
205
+ ```handlebars
206
+ Hello, Gopher!
207
+ ```
208
+
209
+ Prefer Go? Register custom Go functions as well.
210
+
211
+
212
+ ### Share functions
213
+
214
+ Keep your functions in one file and import them from the filesystem or from a URL:
215
+
216
+
217
+
218
+ <!-- prettier-ignore -->
219
+ ```handlebars
220
+ +{{ import "funcs" "https://raw.githubusercontent.com/CodeShellDev/goplater/refs/heads/main/examples/funcs" }}
221
+ +{{ call "funcs.greet" "John" }}
222
+ ```
223
+
224
+
225
+
226
+ Pin remote imports to a tag or a commit and treat them like any other dependency: imported functions run inside your template.
227
+
228
+
229
+ ### Use the engine instead
230
+
231
+ `gplt-engine` is not tied to the CLI.
232
+ Load the modules you want and embed templating in your own Go application.
233
+ Browse the packages on [pkg.go.dev](https://pkg.go.dev/github.com/CodeShellDev/goplater/pkg/gplt).
234
+
235
+ ## Automate with GitHub Actions
236
+
237
+ Use Goplater in your CI/CD workflows to generate files automatically.
238
+
239
+ - **[Goplater GitHub Action](https://github.com/CodeShellDev/goplater-action)**: render templates directly in your GitHub Actions workflows.
240
+ - **[Goplater Bot](https://github.com/CodeShellDev/goplater-action/blob/main/.github/workflows/goplater-bot.yml)**: automate file generation in a repository and have the results submitted as a pull request or pushed as a commit.
241
+
242
+ We use [Goplater Bot](https://github.com/CodeShellDev/goplater-action/blob/main/.github/workflows/goplater-bot.yml) as well, check him out [PR #20](https://github.com/CodeShellDev/goplater/pull/20)!
243
+
244
+ ## Standard Library
245
+
246
+ `gplt-engine` includes a large and growing selection of built-in functions for use in your templates.
247
+ Every module is independent, load all of them or only the ones you need.
248
+
249
+ Goplater ships with all implemented modules in addition to `fs`-specific and cli dependent functions.
250
+
251
+ | Module | Use it for |
252
+ | ----------------------------- | -------------------------------------------------- |
253
+ | `fs` | Reading, writing and walking files and directories |
254
+ | `outputto` | Choosing the output path from inside a template |
255
+ | `strings`, `regex` | Trimming, splitting, replacing, matching |
256
+ | `json`, `yaml` | Decoding and encoding structured data |
257
+ | `html`, `markdown` | Querying and editing documents |
258
+ | `http` | Fetching remote resources |
259
+ | `math` | Operators and number helpers |
260
+ | `container` | Maps and slices |
261
+ | `base64`, `conversion` | Encoding and type conversion |
262
+ | `import`, `return`, `globals` | Sharing functions and passing values around |
263
+ | `debug` | Printing while you develop |
264
+
265
+ Need something that is not there? Add your own with a custom module or your own Goplater function file and share it.
266
+
267
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/internals/template/funcs/fs.go">fs</a></h3>
268
+
269
+
270
+ <table width="100%">
271
+ <tr><th align="left"><h4><code>read(path string) (string, throws error)</code></h4></th>
272
+ </tr><tr><td>
273
+ <p>Reads and templates file.</p>
274
+
275
+
276
+ <details>
277
+ <summary>Examples</summary>
278
+ <br/>
279
+
280
+ **Example**:
281
+ ```handlebars
282
+ +{{ read "/path/to/file" }}
283
+ ```
284
+
285
+ </details>
286
+
287
+ </td></tr></table>
288
+
289
+
290
+ <table width="100%">
291
+ <tr><th align="left"><h4><code>readRaw(path string) (string, throws error)</code></h4></th>
292
+ </tr><tr><td>
293
+ <p>Reads file (without templating).</p>
294
+
295
+
296
+ <details>
297
+ <summary>Examples</summary>
298
+ <br/>
299
+
300
+ **Example**:
301
+ ```handlebars
302
+ +{{ readRaw "/path/to/file" }}
303
+ ```
304
+
305
+ </details>
306
+
307
+ </td></tr></table>
308
+
309
+
310
+ <table width="100%">
311
+ <tr><th align="left"><h4><code>readArgs(path string, args any) (string, throws error)</code></h4></th>
312
+ </tr><tr><td>
313
+ <p>Reads file and passes arguments to it.
314
+ Arguments are available as <code>.arg</code> in the file being read.</p>
315
+
316
+
317
+ <details>
318
+ <summary>Examples</summary>
319
+ <br/>
320
+
321
+ **Example**:
322
+ ```handlebars
323
+ +{{ readArgs "/path/to/file" (sliceCreate "my" "args") }}
324
+ ```
325
+
326
+ </details>
327
+
328
+ </td></tr></table>
329
+
330
+
331
+ <table width="100%">
332
+ <tr><th align="left"><h4><code>write(path string, content string) throws error</code></h4></th>
333
+ </tr><tr><td>
334
+ <p>Writes to a file path.</p>
335
+
336
+
337
+ <details>
338
+ <summary>Examples</summary>
339
+ <br/>
340
+
341
+ **Example**:
342
+ ```handlebars
343
+ +{{ write "/path/to/file" "Hello" }}
344
+ ```
345
+
346
+ </details>
347
+
348
+ </td></tr></table>
349
+
350
+
351
+ <table width="100%">
352
+ <tr><th align="left"><h4><code>mkdir(path string) throws error</code></h4></th>
353
+ </tr><tr><td>
354
+ <p>Creates directory at path.</p>
355
+
356
+
357
+ <details>
358
+ <summary>Examples</summary>
359
+ <br/>
360
+
361
+ **Example**:
362
+ ```handlebars
363
+ +{{ mkdir "/path/to/somewhere/" }}
364
+ ```
365
+
366
+ </details>
367
+
368
+ </td></tr></table>
369
+
370
+
371
+ <table width="100%">
372
+ <tr><th align="left"><h4><code>appendFile(path string, content string) throws error</code></h4></th>
373
+ </tr><tr><td>
374
+ <p>Appends to an existing file.</p>
375
+
376
+
377
+ <details>
378
+ <summary>Examples</summary>
379
+ <br/>
380
+
381
+ **Example**:
382
+ ```handlebars
383
+ +{{ appendFile "/path/to/somewhere/" "Goodbye" }}
384
+ ```
385
+
386
+ </details>
387
+
388
+ </td></tr></table>
389
+
390
+
391
+ <table width="100%">
392
+ <tr><th align="left"><h4><code>fsExists(path string) bool</code></h4></th>
393
+ </tr><tr><td>
394
+ <p>Returns if a file or folder exists at a given path.</p>
395
+
396
+
397
+ <details>
398
+ <summary>Examples</summary>
399
+ <br/>
400
+
401
+ **Example**:
402
+ ```handlebars
403
+ +{{ if (fsExists "/path/to/somewhere") }}
404
+ Path exists!
405
+ +{{ end }}
406
+ ```
407
+
408
+ </details>
409
+
410
+ </td></tr></table>
411
+
412
+
413
+ <table width="100%">
414
+ <tr><th align="left"><h4><code>isFile(path string) bool</code></h4></th>
415
+ </tr><tr><td>
416
+ <p>Returns if a file exists at a given path.</p>
417
+
418
+
419
+ <details>
420
+ <summary>Examples</summary>
421
+ <br/>
422
+
423
+ **Example**:
424
+ ```handlebars
425
+ +{{ if (isFile "/path/to/file") }}
426
+ Path is a file!
427
+ +{{ end }}
428
+ ```
429
+
430
+ </details>
431
+
432
+ </td></tr></table>
433
+
434
+
435
+ <table width="100%">
436
+ <tr><th align="left"><h4><code>isDir(path string) bool</code></h4></th>
437
+ </tr><tr><td>
438
+ <p>Returns if a folder exists at a given path.</p>
439
+
440
+
441
+ <details>
442
+ <summary>Examples</summary>
443
+ <br/>
444
+
445
+ **Example**:
446
+ ```handlebars
447
+ +{{ if (isDir "/path/to/somewhere") }}
448
+ Path is a folder!
449
+ +{{ end }}
450
+ ```
451
+
452
+ </details>
453
+
454
+ </td></tr></table>
455
+
456
+
457
+ <table width="100%">
458
+ <tr><th align="left"><h4><code>listDir(path string) ([]string, throws error)</code></h4></th>
459
+ </tr><tr><td>
460
+ <p>Returns all files and folders inside of a given directory.</p>
461
+
462
+
463
+ <details>
464
+ <summary>Examples</summary>
465
+ <br/>
466
+
467
+ **Example**:
468
+ ```handlebars
469
+ +{{ join ", " (listDir "/path/to") }}
470
+ ```
471
+ **Output**:
472
+ ```
473
+ /path/to/file1.txt, /path/to/file2.txt, /path/to/folder
474
+ ```
475
+
476
+
477
+ </details>
478
+
479
+ </td></tr></table>
480
+
481
+
482
+ <table width="100%">
483
+ <tr><th align="left"><h4><code>walkDir(path string) ([]string, throws error)</code></h4></th>
484
+ </tr><tr><td>
485
+ <p>Returns all files and folders recursively under a given directory.</p>
486
+
487
+
488
+ <details>
489
+ <summary>Examples</summary>
490
+ <br/>
491
+
492
+ **Example**:
493
+ ```handlebars
494
+ +{{ join ", " (walkDir "/path/to") }}
495
+ ```
496
+ **Output**:
497
+ ```
498
+ /path/to/file1.txt, /path/to/file2.txt, /path/to/folder, /path/to/folder/file3.txt
499
+ ```
500
+
501
+
502
+ </details>
503
+
504
+ </td></tr></table>
505
+
506
+
507
+ <table width="100%">
508
+ <tr><th align="left"><h4><code>fsRemove(path string) throws error</code></h4></th>
509
+ </tr><tr><td>
510
+ <p>Removes a file or folder at a given path.</p>
511
+
512
+
513
+ <details>
514
+ <summary>Examples</summary>
515
+ <br/>
516
+
517
+ **Example**:
518
+ ```handlebars
519
+ +{{ fsRemove "/path/to/file/or/folder" }}
520
+ ```
521
+
522
+ </details>
523
+
524
+ </td></tr></table>
525
+
526
+
527
+ <table width="100%">
528
+ <tr><th align="left"><h4><code>joinPath(paths []string) string</code></h4></th>
529
+ </tr><tr><td>
530
+ <p>Joins paths together.</p>
531
+
532
+
533
+ </td></tr></table>
534
+
535
+
536
+ <table width="100%">
537
+ <tr><th align="left"><h4><code>basePath(path string) string</code></h4></th>
538
+ </tr><tr><td>
539
+ <p>Returns the last element of a path.</p>
540
+
541
+
542
+ </td></tr></table>
543
+
544
+
545
+ <table width="100%">
546
+ <tr><th align="left"><h4><code>pathDir(path string) string</code></h4></th>
547
+ </tr><tr><td>
548
+ <p>Returns all but the last element of a path.</p>
549
+
550
+
551
+ </td></tr></table>
552
+
553
+
554
+ <table width="100%">
555
+ <tr><th align="left"><h4><code>fileExt(path string) string</code></h4></th>
556
+ </tr><tr><td>
557
+ <p>Returns the file name extension of a file path.</p>
558
+
559
+
560
+ </td></tr></table>
561
+
562
+
563
+ <table width="100%">
564
+ <tr><th align="left"><h4><code>absPath(path string) (string, throws error)</code></h4></th>
565
+ </tr><tr><td>
566
+ <p>Returns an absolute representation of a given path.
567
+ If the path is not absolute it will be joined with the current working directory to turn it into an absolute path.</p>
568
+
569
+
570
+ </td></tr></table>
571
+
572
+
573
+ <table width="100%">
574
+ <tr><th align="left"><h4><code>relPath(basePath string, targetPath string) (string, throws error)</code></h4></th>
575
+ </tr><tr><td>
576
+ <p>Returns a relative path that is lexically equivalent to targetPath when joined to basePath with an intervening separator.
577
+ The returned path will always be relative to basePath, even if basePath and targetPath share no elements.</p>
578
+
579
+
580
+ </td></tr></table>
581
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/internals/template/funcs/outputto.go">outputto</a></h3>
582
+
583
+
584
+ <table width="100%">
585
+ <tr><th align="left"><h4><code>outputTo(path string) throws error</code></h4></th>
586
+ </tr><tr><td>
587
+ <p>Changes the output path for the current file.
588
+ Errors if path is not allowed.</p>
589
+
590
+
591
+ </td></tr></table>
592
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/container/container.go">container</a></h3>
593
+
594
+
595
+ <table width="100%">
596
+ <tr><th align="left"><h4><code>delete(container map[any]any|[]any, key any) (any, throws error)</code></h4></th>
597
+ </tr><tr><td>
598
+ <p>Deletes a container entry with the given key.</p>
599
+
600
+
601
+ <details>
602
+ <summary>Examples</summary>
603
+ <br/>
604
+
605
+ **Example**:
606
+ ```handlebars
607
+ +{{ $newSlice := delete (sliceCreate "Apple" "Banana") 0 }}
608
+ +{{ echo $newSlice }}
609
+ ```
610
+ **Output**:
611
+ ```
612
+ [Banana]
613
+ ```
614
+
615
+
616
+ </details>
617
+
618
+ </td></tr></table>
619
+
620
+
621
+ <table width="100%">
622
+ <tr><th align="left"><h4><code>set(container map[any]any|[]any, key any, value any) (any, throws error)</code></h4></th>
623
+ </tr><tr><td>
624
+ <p>Set a container entry value with the given key.</p>
625
+
626
+
627
+ <details>
628
+ <summary>Examples</summary>
629
+ <br/>
630
+
631
+ **Example**:
632
+ ```handlebars
633
+ +{{ $newSlice := set (sliceCreate "Apple" "Banana") 0 "Strawberry" }}
634
+ +{{ echo $newSlice }}
635
+ ```
636
+ **Output**:
637
+ ```
638
+ [Strawberry Banana]
639
+ ```
640
+
641
+
642
+ </details>
643
+
644
+ </td></tr></table>
645
+
646
+
647
+ <table width="100%">
648
+ <tr><th align="left"><h4><code>has(container map[any]any|[]any, key any) (bool, throws error)</code></h4></th>
649
+ </tr><tr><td>
650
+ <p>Returns if an entry with the given key exists in container.</p>
651
+
652
+
653
+ <details>
654
+ <summary>Examples</summary>
655
+ <br/>
656
+
657
+ **Example**:
658
+ ```handlebars
659
+ +{{ if (has (mapCreate "version" "v1") "version") }}
660
+ Container has "version"!
661
+ +{{ end }}
662
+ ```
663
+
664
+ </details>
665
+
666
+ </td></tr></table>
667
+
668
+
669
+ <table width="100%">
670
+ <tr><th align="left"><h4><code>slicePush(container []any, value any) []any</code></h4></th>
671
+ </tr><tr><td>
672
+ <p>Appends a value to a slice.</p>
673
+
674
+
675
+ <details>
676
+ <summary>Examples</summary>
677
+ <br/>
678
+
679
+ **Example**:
680
+ ```handlebars
681
+ +{{ $newSlice := sliceCreate "Apple" "Banana" }}
682
+ +{{ $newSlice = slicePush $newSlice "Strawberry" }}
683
+ +{{ echo $newSlice }}
684
+ ```
685
+ **Output**:
686
+ ```
687
+ [Apple Banana Strawberry]
688
+ ```
689
+
690
+
691
+ </details>
692
+
693
+ </td></tr></table>
694
+
695
+
696
+ <table width="100%">
697
+ <tr><th align="left"><h4><code>sliceCreate(values []any) []any</code></h4></th>
698
+ </tr><tr><td>
699
+ <p>Creates a new slice, optionally with values.</p>
700
+
701
+
702
+ <details>
703
+ <summary>Examples</summary>
704
+ <br/>
705
+
706
+ **Example**:
707
+ ```handlebars
708
+ +{{ $newSlice := sliceCreate "Apple" "Banana" }}
709
+ +{{ echo $newSlice }}
710
+ ```
711
+ **Output**:
712
+ ```
713
+ [Apple Banana]
714
+ ```
715
+
716
+
717
+ </details>
718
+
719
+ </td></tr></table>
720
+
721
+
722
+ <table width="100%">
723
+ <tr><th align="left"><h4><code>mapCreate(entries []any) (map[string]any, errors)</code></h4></th>
724
+ </tr><tr><td>
725
+ <p>Creates a new map, optionally with key value pairs.
726
+ Pairs are constructed one by one, a key followed by the given value.
727
+ Currently only supports string keys!</p>
728
+
729
+
730
+ <details>
731
+ <summary>Examples</summary>
732
+ <br/>
733
+
734
+ **Example**:
735
+ ```handlebars
736
+ +{{ $newMap := mapCreate "key1" "value1" "key2" "value2" }}
737
+ +{{ echo $newMap }}
738
+ ```
739
+ **Output**:
740
+ ```
741
+ map[key1:value1 key2:value2]
742
+ ```
743
+
744
+
745
+ </details>
746
+
747
+ </td></tr></table>
748
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/conversion/conversion.go">conversion</a></h3>
749
+
750
+
751
+ <table width="100%">
752
+ <tr><th align="left"><h4><code>toString(value any) string</code></h4></th>
753
+ </tr><tr><td>
754
+ <p>Returns a given value as string (using <a href="https://pkg.go.dev/fmt#Sprint">fmt.Sprint</a>, bytes are handled separately).</p>
755
+
756
+
757
+ </td></tr></table>
758
+
759
+
760
+ <table width="100%">
761
+ <tr><th align="left"><h4><code>toBytes(str string) []byte</code></h4></th>
762
+ </tr><tr><td>
763
+ <p>Turns a string into bytes.</p>
764
+
765
+
766
+ </td></tr></table>
767
+
768
+
769
+ <table width="100%">
770
+ <tr><th align="left"><h4><code>toInt(str string) (int, throws error)</code></h4></th>
771
+ </tr><tr><td>
772
+ <p>Attempts to parse a string as int.</p>
773
+
774
+
775
+ </td></tr></table>
776
+
777
+
778
+ <table width="100%">
779
+ <tr><th align="left"><h4><code>toFloat64(str string) (float64, throws error)</code></h4></th>
780
+ </tr><tr><td>
781
+ <p>Attempts to parse a string as float64.</p>
782
+
783
+
784
+ </td></tr></table>
785
+
786
+
787
+ <table width="100%">
788
+ <tr><th align="left"><h4><code>toFloat32(str string) (float32, throws error)</code></h4></th>
789
+ </tr><tr><td>
790
+ <p>Attempts to parse a string as float32.</p>
791
+
792
+
793
+ </td></tr></table>
794
+
795
+
796
+ <table width="100%">
797
+ <tr><th align="left"><h4><code>toBool(str string) (bool, throws error)</code></h4></th>
798
+ </tr><tr><td>
799
+ <p>Attempts to parse a string as a bool (using <a href="https://pkg.go.dev/strconv#ParseBool">strconv.ParseBool</a>).</p>
800
+
801
+
802
+ </td></tr></table>
803
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/core/globals.go">globals</a></h3>
804
+
805
+
806
+ <table width="100%">
807
+ <tr><th align="left"><h4><code>globalSet(key string, value any) throws error</code></h4></th>
808
+ </tr><tr><td>
809
+ <p>Defines a global value with a key.</p>
810
+
811
+
812
+ </td></tr></table>
813
+
814
+
815
+ <table width="100%">
816
+ <tr><th align="left"><h4><code>globalGet(key string) (any, throws error)</code></h4></th>
817
+ </tr><tr><td>
818
+ <p>Tries to retrieve a global value with a key.</p>
819
+
820
+
821
+ </td></tr></table>
822
+
823
+
824
+ <table width="100%">
825
+ <tr><th align="left"><h4><code>globalHas(key string) bool</code></h4></th>
826
+ </tr><tr><td>
827
+ <p>Returns whether a given global variable exists.</p>
828
+
829
+
830
+ </td></tr></table>
831
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/core/import.go">import</a></h3>
832
+
833
+
834
+ <table width="100%">
835
+ <tr><th align="left"><h4><code>import(alias string?, path string) throws error</code></h4></th>
836
+ </tr><tr><td>
837
+ <p>Tries to import a template file with func definitions.
838
+ Optionally supply an alias for easier access.
839
+ The fs resolver is only available as an internal module and does not ship with the <code>pkg/gplt/modules</code> directory.</p>
840
+
841
+
842
+ <details>
843
+ <summary>Examples</summary>
844
+ <br/>
845
+
846
+ **Example**:
847
+ ```handlebars
848
+ +{{ import "https://domain.com/functions" }}
849
+ ```
850
+ **Output**:
851
+ ```
852
+ +{{ call "functions.greet" "John" }}
853
+ ```
854
+
855
+
856
+ **Example**:
857
+ ```handlebars
858
+ +{{ import "funcs" "https://domain.com/functions" }}
859
+ ```
860
+ **Output**:
861
+ ```
862
+ +{{ call "funcs.greet" "John" }}
863
+ ```
864
+
865
+
866
+ </details>
867
+
868
+ </td></tr></table>
869
+
870
+
871
+ <table width="100%">
872
+ <tr><th align="left"><h4><code>importExact(alias string?, path string, hash string?) throws error</code></h4></th>
873
+ </tr><tr><td>
874
+ <p>Same <code>import</code>, but only imports if content matches expected SHA-256 hash.</p>
875
+
876
+
877
+ <details>
878
+ <summary>Examples</summary>
879
+ <br/>
880
+
881
+ **Example**:
882
+ ```handlebars
883
+ +{{ importExact "funcs" "https://domain.com/functions" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }}
884
+ ```
885
+ **Output**:
886
+ ```
887
+ +{{ call "funcs.greet" "John" }}
888
+ ```
889
+
890
+
891
+ </details>
892
+
893
+ </td></tr></table>
894
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/core/return.go">return</a></h3>
895
+
896
+
897
+ <table width="100%">
898
+ <tr><th align="left"><h4><code>return(i int, value any) throws error</code></h4></th>
899
+ </tr><tr><td>
900
+ <p>Sets an output value at the given index.</p>
901
+
902
+
903
+ </td></tr></table>
904
+
905
+
906
+ <table width="100%">
907
+ <tr><th align="left"><h4><code>returnNext(value any) throws error</code></h4></th>
908
+ </tr><tr><td>
909
+ <p>Appends a value to the output.</p>
910
+
911
+
912
+ </td></tr></table>
913
+
914
+
915
+ <table width="100%">
916
+ <tr><th align="left"><h4><code>returnAll(value []any) throws error</code></h4></th>
917
+ </tr><tr><td>
918
+ <p>Sets the output object as a whole.</p>
919
+
920
+
921
+ <details>
922
+ <summary>Examples</summary>
923
+ <br/>
924
+
925
+ **Example**:
926
+ ```handlebars
927
+ +{{ returnAll "1" "2" "3" }}
928
+ +{{ returnAll (sliceCreate "1" "2" "3") }}
929
+ ```
930
+
931
+ </details>
932
+
933
+ </td></tr></table>
934
+
935
+
936
+ <table width="100%">
937
+ <tr><th align="left"><h4><code>getOutputs() []any</code></h4></th>
938
+ </tr><tr><td>
939
+ <p>Returns current outputs.</p>
940
+
941
+
942
+ </td></tr></table>
943
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/debug/debug.go">debug</a></h3>
944
+
945
+
946
+ <table width="100%">
947
+ <tr><th align="left"><h4><code>echo(data []any)</code></h4></th>
948
+ </tr><tr><td>
949
+ <p>Outputs data to stdout.</p>
950
+
951
+
952
+ </td></tr></table>
953
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/encoding/base64.go">base64</a></h3>
954
+
955
+
956
+ <table width="100%">
957
+ <tr><th align="left"><h4><code>base64Encode(str string) string</code></h4></th>
958
+ </tr><tr><td>
959
+ <p>Encodes strings with base64.</p>
960
+
961
+
962
+ </td></tr></table>
963
+
964
+
965
+ <table width="100%">
966
+ <tr><th align="left"><h4><code>base64Decode(str string) (string, throws error)</code></h4></th>
967
+ </tr><tr><td>
968
+ <p>Decodes a base64 string.</p>
969
+
970
+
971
+ </td></tr></table>
972
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/encoding/hex.go">hex</a></h3>
973
+
974
+
975
+ <table width="100%">
976
+ <tr><th align="left"><h4><code>hexEncode(str string) string</code></h4></th>
977
+ </tr><tr><td>
978
+ <p>Encodes a string as hex.</p>
979
+
980
+
981
+ </td></tr></table>
982
+
983
+
984
+ <table width="100%">
985
+ <tr><th align="left"><h4><code>hexDecode(str string) (string, throws error)</code></h4></th>
986
+ </tr><tr><td>
987
+ <p>Decodes a string as hex.</p>
988
+
989
+
990
+ </td></tr></table>
991
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/hash/hash.go">hash</a></h3>
992
+
993
+
994
+ <table width="100%">
995
+ <tr><th align="left"><h4><code>hash(str string)</code></h4></th>
996
+ </tr><tr><td>
997
+ <p>Hashes a given string with SHA-256.</p>
998
+
999
+
1000
+ </td></tr></table>
1001
+
1002
+
1003
+ <table width="100%">
1004
+ <tr><th align="left"><h4><code>sha1(str string)</code></h4></th>
1005
+ </tr><tr><td>
1006
+ <p>Hashes a given string with SHA-1.</p>
1007
+
1008
+
1009
+ </td></tr></table>
1010
+
1011
+
1012
+ <table width="100%">
1013
+ <tr><th align="left"><h4><code>sha512(str string)</code></h4></th>
1014
+ </tr><tr><td>
1015
+ <p>Hashes a given string with SHA-512.</p>
1016
+
1017
+
1018
+ </td></tr></table>
1019
+
1020
+
1021
+ <table width="100%">
1022
+ <tr><th align="left"><h4><code>md5(str string)</code></h4></th>
1023
+ </tr><tr><td>
1024
+ <p>Hashes a given string with MD-5.</p>
1025
+
1026
+
1027
+ </td></tr></table>
1028
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/html/html.go">html</a></h3>
1029
+
1030
+
1031
+ <table width="100%">
1032
+ <tr><th align="left"><h4><code>htmlDecode(html string) (*goquery.Document, throws error)</code></h4></th>
1033
+ </tr><tr><td>
1034
+ <p>Decodes html into a document.</p>
1035
+
1036
+
1037
+ </td></tr></table>
1038
+
1039
+
1040
+ <table width="100%">
1041
+ <tr><th align="left"><h4><code>htmlDocFindAll(doc *goquery.Document, selector string) ([]*goquery.Selection, throws error)</code></h4></th>
1042
+ </tr><tr><td>
1043
+ <p>Finds elements in document by selector (using <a href="https://pkg.go.dev/github.com/PuerkitoBio/goquery#Selection.Find">goquery.Find</a>).</p>
1044
+
1045
+
1046
+ </td></tr></table>
1047
+
1048
+
1049
+ <table width="100%">
1050
+ <tr><th align="left"><h4><code>htmlDocFind(doc *goquery.Document, selector string) (*goquery.Selection, throws error)</code></h4></th>
1051
+ </tr><tr><td>
1052
+ <p>Finds element in document by selector (using <a href="https://pkg.go.dev/github.com/PuerkitoBio/goquery#Selection.Find">goquery.Find</a>).</p>
1053
+
1054
+
1055
+ </td></tr></table>
1056
+
1057
+
1058
+ <table width="100%">
1059
+ <tr><th align="left"><h4><code>htmlFindAll(doc *goquery.Document, selector string) ([]*goquery.Selection, throws error)</code></h4></th>
1060
+ </tr><tr><td>
1061
+ <p>Finds elements in element by selector (using <a href="https://pkg.go.dev/github.com/PuerkitoBio/goquery#Selection.Find">goquery.Find</a>).</p>
1062
+
1063
+
1064
+ </td></tr></table>
1065
+
1066
+
1067
+ <table width="100%">
1068
+ <tr><th align="left"><h4><code>htmlFind(doc *goquery.Document, selector string) (*goquery.Selection, throws error)</code></h4></th>
1069
+ </tr><tr><td>
1070
+ <p>Finds element in element by selector (using <a href="https://pkg.go.dev/github.com/PuerkitoBio/goquery#Selection.Find">goquery.Find</a>).</p>
1071
+
1072
+
1073
+ </td></tr></table>
1074
+
1075
+
1076
+ <table width="100%">
1077
+ <tr><th align="left"><h4><code>htmlText(el *goquery.Selection) string</code></h4></th>
1078
+ </tr><tr><td>
1079
+ <p>Returns the elements text content.</p>
1080
+
1081
+
1082
+ </td></tr></table>
1083
+
1084
+
1085
+ <table width="100%">
1086
+ <tr><th align="left"><h4><code>htmlAttr(el *goquery.Selection, attr string) string</code></h4></th>
1087
+ </tr><tr><td>
1088
+ <p>Returns an elements attribute content.</p>
1089
+
1090
+
1091
+ </td></tr></table>
1092
+
1093
+
1094
+ <table width="100%">
1095
+ <tr><th align="left"><h4><code>htmlInner(el *goquery.Selection) string</code></h4></th>
1096
+ </tr><tr><td>
1097
+ <p>Returns the elements inner html.</p>
1098
+
1099
+
1100
+ </td></tr></table>
1101
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/http/http.go">http</a></h3>
1102
+
1103
+
1104
+ <table width="100%">
1105
+ <tr><th align="left"><h4><code>fetch(url string) (string, throws error)</code></h4></th>
1106
+ </tr><tr><td>
1107
+ <p>Fetches a resource from a given url.
1108
+ Outputs errors as string.</p>
1109
+
1110
+
1111
+ </td></tr></table>
1112
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/json/json.go">json</a></h3>
1113
+
1114
+
1115
+ <table width="100%">
1116
+ <tr><th align="left"><h4><code>jsonEncode(obj any) (string, throws error)</code></h4></th>
1117
+ </tr><tr><td>
1118
+ <p>Encodes an object into a json string.</p>
1119
+
1120
+
1121
+ </td></tr></table>
1122
+
1123
+
1124
+ <table width="100%">
1125
+ <tr><th align="left"><h4><code>jsonDecode(json string) (any, throws error)</code></h4></th>
1126
+ </tr><tr><td>
1127
+ <p>Decodes a json string into an object.</p>
1128
+
1129
+
1130
+ </td></tr></table>
1131
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/markdown/markdown.go">markdown</a></h3>
1132
+
1133
+
1134
+ <table width="100%">
1135
+ <tr><th align="left"><h4><code>markdownDecode(md string) *Document</code></h4></th>
1136
+ </tr><tr><td>
1137
+ <p>Decodes markdown into a document.</p>
1138
+
1139
+
1140
+ </td></tr></table>
1141
+
1142
+
1143
+ <table width="100%">
1144
+ <tr><th align="left"><h4><code>markdownEncode(doc *Document) string</code></h4></th>
1145
+ </tr><tr><td>
1146
+ <p>Encodes a document into markdown.</p>
1147
+
1148
+
1149
+ </td></tr></table>
1150
+
1151
+
1152
+ <table width="100%">
1153
+ <tr><th align="left"><h4><code>markdownFindAll(target Searchable, selector string) []*Node</code></h4></th>
1154
+ </tr><tr><td>
1155
+ <p>Finds elements in target by selector (using <a href="https://pkg.go.dev/github.com/codeshelldev/goplater/pkg/gplt/modules/markdown#TypeMatches">custom</a>).</p>
1156
+
1157
+
1158
+ </td></tr></table>
1159
+
1160
+
1161
+ <table width="100%">
1162
+ <tr><th align="left"><h4><code>markdownFind(target Searchable, selector string) *Node</code></h4></th>
1163
+ </tr><tr><td>
1164
+ <p>Finds element in target by selector (using <a href="https://pkg.go.dev/github.com/codeshelldev/goplater/pkg/gplt/modules/markdown#TypeMatches">custom</a>).</p>
1165
+
1166
+
1167
+ </td></tr></table>
1168
+
1169
+
1170
+ <table width="100%">
1171
+ <tr><th align="left"><h4><code>markdownIs(node *Node, selector string) bool</code></h4></th>
1172
+ </tr><tr><td>
1173
+ <p>Returns whether node matches selector (using <a href="https://pkg.go.dev/github.com/codeshelldev/goplater/pkg/gplt/modules/markdown#TypeMatches">custom</a>).</p>
1174
+
1175
+
1176
+ </td></tr></table>
1177
+
1178
+
1179
+ <table width="100%">
1180
+ <tr><th align="left"><h4><code>markdownHTML(doc *Document) (string, throws error)</code></h4></th>
1181
+ </tr><tr><td>
1182
+ <p>Returns html markdown representation.</p>
1183
+
1184
+
1185
+ </td></tr></table>
1186
+
1187
+
1188
+ <table width="100%">
1189
+ <tr><th align="left"><h4><code>markdownText(node *Node) string</code></h4></th>
1190
+ </tr><tr><td>
1191
+ <p>Returns all raw markdown text in a node recursively.</p>
1192
+
1193
+
1194
+ </td></tr></table>
1195
+
1196
+
1197
+ <table width="100%">
1198
+ <tr><th align="left"><h4><code>markdownHeadings(doc *Document) []*Heading</code></h4></th>
1199
+ </tr><tr><td>
1200
+ <p>Returns all markdown headings.</p>
1201
+
1202
+
1203
+ </td></tr></table>
1204
+
1205
+
1206
+ <table width="100%">
1207
+ <tr><th align="left"><h4><code>markdownLinks(doc *Document) []*Link</code></h4></th>
1208
+ </tr><tr><td>
1209
+ <p>Returns all markdown links.</p>
1210
+
1211
+
1212
+ </td></tr></table>
1213
+
1214
+
1215
+ <table width="100%">
1216
+ <tr><th align="left"><h4><code>markdownLinkURL(link *Link) string</code></h4></th>
1217
+ </tr><tr><td>
1218
+ <p>Returns the url of a markdown link node.</p>
1219
+
1220
+
1221
+ </td></tr></table>
1222
+
1223
+
1224
+ <table width="100%">
1225
+ <tr><th align="left"><h4><code>markdownLinkSetURL(link *Link, url string)</code></h4></th>
1226
+ </tr><tr><td>
1227
+ <p>Sets a link node's url.</p>
1228
+
1229
+
1230
+ </td></tr></table>
1231
+
1232
+
1233
+ <table width="100%">
1234
+ <tr><th align="left"><h4><code>markdownLinkSetTitle(link *Link, title string)</code></h4></th>
1235
+ </tr><tr><td>
1236
+ <p>Sets a link node's title.</p>
1237
+
1238
+
1239
+ </td></tr></table>
1240
+
1241
+
1242
+ <table width="100%">
1243
+ <tr><th align="left"><h4><code>markdownLinkText(link *Link) string</code></h4></th>
1244
+ </tr><tr><td>
1245
+ <p>Returns the text of a markdown link node.</p>
1246
+
1247
+
1248
+ </td></tr></table>
1249
+
1250
+
1251
+ <table width="100%">
1252
+ <tr><th align="left"><h4><code>markdownImages(doc *Document) []*Image</code></h4></th>
1253
+ </tr><tr><td>
1254
+ <p>Returns all markdown images.</p>
1255
+
1256
+
1257
+ </td></tr></table>
1258
+
1259
+
1260
+ <table width="100%">
1261
+ <tr><th align="left"><h4><code>markdownImageURL(image *Image) string</code></h4></th>
1262
+ </tr><tr><td>
1263
+ <p>Returns the url of a markdown image node.</p>
1264
+
1265
+
1266
+ </td></tr></table>
1267
+
1268
+
1269
+ <table width="100%">
1270
+ <tr><th align="left"><h4><code>markdownImageSetURL(image *Image, url string)</code></h4></th>
1271
+ </tr><tr><td>
1272
+ <p>Sets a image node's url.</p>
1273
+
1274
+
1275
+ </td></tr></table>
1276
+
1277
+
1278
+ <table width="100%">
1279
+ <tr><th align="left"><h4><code>markdownImageSetAlt(image *Image, alt string)</code></h4></th>
1280
+ </tr><tr><td>
1281
+ <p>Sets a image node's alt.</p>
1282
+
1283
+
1284
+ </td></tr></table>
1285
+
1286
+
1287
+ <table width="100%">
1288
+ <tr><th align="left"><h4><code>markdownParagraphs(doc *Document) []*Paragraph</code></h4></th>
1289
+ </tr><tr><td>
1290
+ <p>Returns all markdown paragraphs.</p>
1291
+
1292
+
1293
+ </td></tr></table>
1294
+
1295
+
1296
+ <table width="100%">
1297
+ <tr><th align="left"><h4><code>markdownCodeBlocks(doc *Document) []*CodeBlock</code></h4></th>
1298
+ </tr><tr><td>
1299
+ <p>Returns all markdown code blocks.</p>
1300
+
1301
+
1302
+ </td></tr></table>
1303
+
1304
+
1305
+ <table width="100%">
1306
+ <tr><th align="left"><h4><code>markdownBlockquotes(doc *Document) []*Blockquote</code></h4></th>
1307
+ </tr><tr><td>
1308
+ <p>Returns all markdown block quotes.</p>
1309
+
1310
+
1311
+ </td></tr></table>
1312
+
1313
+
1314
+ <table width="100%">
1315
+ <tr><th align="left"><h4><code>markdownRemove(node *Node)</code></h4></th>
1316
+ </tr><tr><td>
1317
+ <p>Removes a markdown node.</p>
1318
+
1319
+
1320
+ </td></tr></table>
1321
+
1322
+
1323
+ <table width="100%">
1324
+ <tr><th align="left"><h4><code>markdownAppend(doc *Document, str string)</code></h4></th>
1325
+ </tr><tr><td>
1326
+ <p>Appends text to a markdown document.</p>
1327
+
1328
+
1329
+ </td></tr></table>
1330
+
1331
+
1332
+ <table width="100%">
1333
+ <tr><th align="left"><h4><code>markdownPrepend(doc *Document, str string)</code></h4></th>
1334
+ </tr><tr><td>
1335
+ <p>Prepends text to a markdown document.</p>
1336
+
1337
+
1338
+ </td></tr></table>
1339
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/math/formulas.go">formulas</a></h3>
1340
+
1341
+
1342
+ <table width="100%">
1343
+ <tr><th align="left"><h4><code>abs(numbers int|float64) (int|float64, throws error)</code></h4></th>
1344
+ </tr><tr><td>
1345
+ <p>Returns the abs value of a number.</p>
1346
+
1347
+
1348
+ </td></tr></table>
1349
+
1350
+
1351
+ <table width="100%">
1352
+ <tr><th align="left"><h4><code>min(a int|float64, b int|float64) (int|float64, throws error)</code></h4></th>
1353
+ </tr><tr><td>
1354
+ <p>Returns the smaller value of two numbers.</p>
1355
+
1356
+
1357
+ </td></tr></table>
1358
+
1359
+
1360
+ <table width="100%">
1361
+ <tr><th align="left"><h4><code>max(a int|float64, b int|float64) (int|float64, throws error)</code></h4></th>
1362
+ </tr><tr><td>
1363
+ <p>Returns the bigger value of two numbers.</p>
1364
+
1365
+
1366
+ </td></tr></table>
1367
+
1368
+
1369
+ <table width="100%">
1370
+ <tr><th align="left"><h4><code>clamp(value int|float64, min int|float64, max int|float64) (int|float64, throws error)</code></h4></th>
1371
+ </tr><tr><td>
1372
+ <p>Clamps a value between a minimum and maximum value.</p>
1373
+
1374
+
1375
+ </td></tr></table>
1376
+
1377
+
1378
+ <table width="100%">
1379
+ <tr><th align="left"><h4><code>pow(base int|float64, exponent int|float64) (float64, throws error)</code></h4></th>
1380
+ </tr><tr><td>
1381
+ <p>Performs pow on base with exponent.</p>
1382
+
1383
+
1384
+ </td></tr></table>
1385
+
1386
+
1387
+ <table width="100%">
1388
+ <tr><th align="left"><h4><code>sqrt(number int|float64) (float64, throws error)</code></h4></th>
1389
+ </tr><tr><td>
1390
+ <p>Returns the square root of a number.</p>
1391
+
1392
+
1393
+ </td></tr></table>
1394
+
1395
+
1396
+ <table width="100%">
1397
+ <tr><th align="left"><h4><code>round(number int|float64) (int, throws error)</code></h4></th>
1398
+ </tr><tr><td>
1399
+ <p>Rounds a number to the nearest integer.</p>
1400
+
1401
+
1402
+ </td></tr></table>
1403
+
1404
+
1405
+ <table width="100%">
1406
+ <tr><th align="left"><h4><code>floor(number int|float64) (int, throws error)</code></h4></th>
1407
+ </tr><tr><td>
1408
+ <p>Returns the greatest integer value less than or equal to number.</p>
1409
+
1410
+
1411
+ </td></tr></table>
1412
+
1413
+
1414
+ <table width="100%">
1415
+ <tr><th align="left"><h4><code>ceil(number int|float64) (int, throws error)</code></h4></th>
1416
+ </tr><tr><td>
1417
+ <p>Returns the least integer value greater than or equal to number.</p>
1418
+
1419
+
1420
+ </td></tr></table>
1421
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/math/operators.go">operators</a></h3>
1422
+
1423
+
1424
+ <table width="100%">
1425
+ <tr><th align="left"><h4><code>add(numbers [](int|float64)) (int|float64, throws error)</code></h4></th>
1426
+ </tr><tr><td>
1427
+ <p>Adds numbers together.</p>
1428
+
1429
+
1430
+ </td></tr></table>
1431
+
1432
+
1433
+ <table width="100%">
1434
+ <tr><th align="left"><h4><code>sub(numbers [](int|float64)) (int|float64, throws error)</code></h4></th>
1435
+ </tr><tr><td>
1436
+ <p>Subtracts numbers from each other.</p>
1437
+
1438
+
1439
+ </td></tr></table>
1440
+
1441
+
1442
+ <table width="100%">
1443
+ <tr><th align="left"><h4><code>mult(numbers [](int|float64)) (int|float64, throws error)</code></h4></th>
1444
+ </tr><tr><td>
1445
+ <p>Multiplies numbers together.</p>
1446
+
1447
+
1448
+ </td></tr></table>
1449
+
1450
+
1451
+ <table width="100%">
1452
+ <tr><th align="left"><h4><code>divd(numbers [](int|float64)) (int|float64, throws error)</code></h4></th>
1453
+ </tr><tr><td>
1454
+ <p>Divides numbers from each other.</p>
1455
+
1456
+
1457
+ </td></tr></table>
1458
+
1459
+
1460
+ <table width="100%">
1461
+ <tr><th align="left"><h4><code>mod(numbers [](int|float64)) (int|float64, throws error)</code></h4></th>
1462
+ </tr><tr><td>
1463
+ <p>Performs modulo on numbers.</p>
1464
+
1465
+
1466
+ </td></tr></table>
1467
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/regex/regex.go">regex</a></h3>
1468
+
1469
+
1470
+ <table width="100%">
1471
+ <tr><th align="left"><h4><code>regexMatch(regex string) (bool, throws error)</code></h4></th>
1472
+ </tr><tr><td>
1473
+ <p>Returns whether a string matches the given regex pattern.</p>
1474
+
1475
+
1476
+ </td></tr></table>
1477
+
1478
+
1479
+ <table width="100%">
1480
+ <tr><th align="left"><h4><code>regexFind(regex string) ([]string, throws error)</code></h4></th>
1481
+ </tr><tr><td>
1482
+ <p>Returns all matches against the given regex pattern in a string.</p>
1483
+
1484
+
1485
+ </td></tr></table>
1486
+
1487
+
1488
+ <table width="100%">
1489
+ <tr><th align="left"><h4><code>regexFindGroups(regex string) ([][]string, throws error)</code></h4></th>
1490
+ </tr><tr><td>
1491
+ <p>Returns all matches and submatches from the given regex pattern in a string.</p>
1492
+
1493
+
1494
+ </td></tr></table>
1495
+
1496
+
1497
+ <table width="100%">
1498
+ <tr><th align="left"><h4><code>regexFindGroupsIndex(regex string) ([][]int, throws error)</code></h4></th>
1499
+ </tr><tr><td>
1500
+ <p>Returns all match and submatch positions from the given regex pattern in a string.</p>
1501
+
1502
+
1503
+ </td></tr></table>
1504
+
1505
+
1506
+ <table width="100%">
1507
+ <tr><th align="left"><h4><code>regexReplace(regex string) (string, throws error)</code></h4></th>
1508
+ </tr><tr><td>
1509
+ <p>Replaces all matches from the given regex pattern in a string with the replaceWith param (which allows using '$1', etc.).</p>
1510
+
1511
+
1512
+ </td></tr></table>
1513
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/strings/strings.go">strings</a></h3>
1514
+
1515
+
1516
+ <table width="100%">
1517
+ <tr><th align="left"><h4><code>trimSpace(str string) string</code></h4></th>
1518
+ </tr><tr><td>
1519
+ <p>Trims space from a string (leading and trailing).</p>
1520
+
1521
+
1522
+ </td></tr></table>
1523
+
1524
+
1525
+ <table width="100%">
1526
+ <tr><th align="left"><h4><code>trim(str string, cutset string) string</code></h4></th>
1527
+ </tr><tr><td>
1528
+ <p>Trims all chars defined in the cutset param from a string (leading and trailing).</p>
1529
+
1530
+
1531
+ </td></tr></table>
1532
+
1533
+
1534
+ <table width="100%">
1535
+ <tr><th align="left"><h4><code>upper(str string) string</code></h4></th>
1536
+ </tr><tr><td>
1537
+ <p>Uppercases a string.</p>
1538
+
1539
+
1540
+ </td></tr></table>
1541
+
1542
+
1543
+ <table width="100%">
1544
+ <tr><th align="left"><h4><code>lower(str string) string</code></h4></th>
1545
+ </tr><tr><td>
1546
+ <p>Lowercases a string.</p>
1547
+
1548
+
1549
+ </td></tr></table>
1550
+
1551
+
1552
+ <table width="100%">
1553
+ <tr><th align="left"><h4><code>contains(str string, sub string) bool</code></h4></th>
1554
+ </tr><tr><td>
1555
+ <p>Returns whether a string contains the given substring.</p>
1556
+
1557
+
1558
+ </td></tr></table>
1559
+
1560
+
1561
+ <table width="100%">
1562
+ <tr><th align="left"><h4><code>count(str string, sub string) int</code></h4></th>
1563
+ </tr><tr><td>
1564
+ <p>Counts all occurences of a substring in the given string.</p>
1565
+
1566
+
1567
+ </td></tr></table>
1568
+
1569
+
1570
+ <table width="100%">
1571
+ <tr><th align="left"><h4><code>startsWith(str string, prefix string) bool</code></h4></th>
1572
+ </tr><tr><td>
1573
+ <p>Returns whether a string starts with the given prefix.</p>
1574
+
1575
+
1576
+ </td></tr></table>
1577
+
1578
+
1579
+ <table width="100%">
1580
+ <tr><th align="left"><h4><code>endsWith(str string, suffix string) bool</code></h4></th>
1581
+ </tr><tr><td>
1582
+ <p>Returns whether a string ends with the given suffix.</p>
1583
+
1584
+
1585
+ </td></tr></table>
1586
+
1587
+
1588
+ <table width="100%">
1589
+ <tr><th align="left"><h4><code>isEmpty(str string) bool</code></h4></th>
1590
+ </tr><tr><td>
1591
+ <p>Returns whether the given string is empty.</p>
1592
+
1593
+
1594
+ </td></tr></table>
1595
+
1596
+
1597
+ <table width="100%">
1598
+ <tr><th align="left"><h4><code>replace(str string, sub string, replaceWith string) string</code></h4></th>
1599
+ </tr><tr><td>
1600
+ <p>Replaces all occurences of a substring in the given string with the replaceWith param.</p>
1601
+
1602
+
1603
+ </td></tr></table>
1604
+
1605
+
1606
+ <table width="100%">
1607
+ <tr><th align="left"><h4><code>split(str string, sep string) []string</code></h4></th>
1608
+ </tr><tr><td>
1609
+ <p>Split a string by the given seperator.</p>
1610
+
1611
+
1612
+ </td></tr></table>
1613
+
1614
+
1615
+ <table width="100%">
1616
+ <tr><th align="left"><h4><code>after(str string, sub string) string</code></h4></th>
1617
+ </tr><tr><td>
1618
+ <p>Returns the string after the given substring in a string.</p>
1619
+
1620
+
1621
+ </td></tr></table>
1622
+
1623
+
1624
+ <table width="100%">
1625
+ <tr><th align="left"><h4><code>afterLast(str string, sub string) string</code></h4></th>
1626
+ </tr><tr><td>
1627
+ <p>Returns the string after the last occurrence of the given substring.</p>
1628
+
1629
+
1630
+ </td></tr></table>
1631
+
1632
+
1633
+ <table width="100%">
1634
+ <tr><th align="left"><h4><code>before(str string, sub string) string</code></h4></th>
1635
+ </tr><tr><td>
1636
+ <p>Returns the string before the given substring in a string.</p>
1637
+
1638
+
1639
+ </td></tr></table>
1640
+
1641
+
1642
+ <table width="100%">
1643
+ <tr><th align="left"><h4><code>beforeLast(str string, sub string) string</code></h4></th>
1644
+ </tr><tr><td>
1645
+ <p>Returns the string before the last occurrence of the given substring.</p>
1646
+
1647
+
1648
+ </td></tr></table>
1649
+
1650
+
1651
+ <table width="100%">
1652
+ <tr><th align="left"><h4><code>between(str string, startSub string, endSub string) string</code></h4></th>
1653
+ </tr><tr><td>
1654
+ <p>Returns the substring between the start and end substring.</p>
1655
+
1656
+
1657
+ </td></tr></table>
1658
+
1659
+
1660
+ <table width="100%">
1661
+ <tr><th align="left"><h4><code>cutPrefix(str string, sub string) string</code></h4></th>
1662
+ </tr><tr><td>
1663
+ <p>Removes a substring at the start of the given string.</p>
1664
+
1665
+
1666
+ </td></tr></table>
1667
+
1668
+
1669
+ <table width="100%">
1670
+ <tr><th align="left"><h4><code>cutSuffix(str string, sub string) string</code></h4></th>
1671
+ </tr><tr><td>
1672
+ <p>Removes a substring at the end of the given string.</p>
1673
+
1674
+
1675
+ </td></tr></table>
1676
+
1677
+
1678
+ <table width="100%">
1679
+ <tr><th align="left"><h4><code>slice(str string, start int, end int) string</code></h4></th>
1680
+ </tr><tr><td>
1681
+ <p>Slices a string based on start and end index.</p>
1682
+
1683
+
1684
+ </td></tr></table>
1685
+
1686
+
1687
+ <table width="100%">
1688
+ <tr><th align="left"><h4><code>join(sep string, strings []string) string</code></h4></th>
1689
+ </tr><tr><td>
1690
+ <p>Joins multiple strings together by the given separator.</p>
1691
+
1692
+
1693
+ </td></tr></table>
1694
+
1695
+
1696
+ <table width="100%">
1697
+ <tr><th align="left"><h4><code>repeat(str string, count int) string</code></h4></th>
1698
+ </tr><tr><td>
1699
+ <p>Repeat a string n times.</p>
1700
+
1701
+
1702
+ </td></tr></table>
1703
+ <h3><a href="https://github.com/codeshelldev/goplater/blob/main/pkg/gplt/modules/yaml/yaml.go">yaml</a></h3>
1704
+
1705
+
1706
+ <table width="100%">
1707
+ <tr><th align="left"><h4><code>yamlEncode(obj any) (string, throws error)</code></h4></th>
1708
+ </tr><tr><td>
1709
+ <p>Encodes an object into a yaml string.</p>
1710
+
1711
+
1712
+ </td></tr></table>
1713
+
1714
+
1715
+ <table width="100%">
1716
+ <tr><th align="left"><h4><code>yamlDecode(yaml string) (any, throws error)</code></h4></th>
1717
+ </tr><tr><td>
1718
+ <p>Decodes a yaml string into an object.</p>
1719
+
1720
+
1721
+ </td></tr></table>
1722
+
1723
+
1724
+ ## Contributing
1725
+
1726
+ Found a bug or just want to change or add something?
1727
+ Feel free to open up an issue or a PR!
1728
+
1729
+ ## Support
1730
+
1731
+ Like this Project? Or just want to help?
1732
+ Why not ⭐️ this Repo? :)
1733
+
1734
+ ## License
1735
+
1736
+ This Project is licensed under the [MIT License](./LICENSE).
1737
+
1738
+ ## Legal
1739
+
1740
+ Logo designed by [@CodeShellDev](https://github.com/CodeShellDev) — All Rights Reserved.
1741
+
1742
+ Go gopher mascot originally created by [Renée French](https://instagram.com/reneefrench/),
1743
+ used under the [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) license.