Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit 2ca9a9e

Browse files
authored
Merge pull request #91 from bketelsen/docs/evenmoar
docs: links to monorepo examples
2 parents dfe977a + f39556c commit 2ca9a9e

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

dogfood/sites/docs/docs/recipes/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ The following recipes show some suggestions on ways to consume your CueBlox data
1212
* [Serve data over GraphQL](/recipes/graphql)
1313

1414

15+
## Patterns
1516

17+
* [The MonoRepo](/recipes/monorepo)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# The MonoRepo
3+
4+
## Co-Locate Data and Consumers
5+
6+
See our personal examples:
7+
8+
* [Brian](https://github.com/bketelsen/bkml)
9+
* [David](https://github.com/rawkode/rawkode)

internal/cmd/blox_render.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"path"
1010
"path/filepath"
1111
tpl "text/template"
12+
"time"
1213

1314
"github.com/cueblox/blox"
1415
"github.com/cueblox/blox/internal/cuedb"
@@ -127,10 +128,27 @@ func newBloxRenderCmd() *bloxRenderCmd {
127128
cobra.CheckErr(err)
128129
var dataJson map[string]interface{}
129130

131+
funcMap := tpl.FuncMap{
132+
// The name "title" is what the function will be called in the template text.
133+
"rfcdate": func(t string) string {
134+
tm, err := time.Parse("2006-01-02 15:04", t)
135+
if err != nil {
136+
return err.Error()
137+
}
138+
val := tm.Format(time.RFC1123)
139+
return val
140+
},
141+
"now": func() string {
142+
tm := time.Now()
143+
val := tm.Format(time.RFC1123)
144+
return val
145+
},
146+
}
147+
130148
err = json.Unmarshal(jso, &dataJson)
131149
cobra.CheckErr(err)
132150

133-
t := tpl.Must(tpl.New(template).ParseFiles(paths...))
151+
t := tpl.Must(tpl.New(template).Funcs(funcMap).ParseFiles(paths...))
134152
if with != "" {
135153
if each {
136154
dataset, ok := dataJson[with].([]interface{})

0 commit comments

Comments
 (0)