This repository was archived by the owner on Sep 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
dogfood/sites/docs/docs/recipes Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 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 {})
You can’t perform that action at this time.
0 commit comments