@bookshop/hugo-engine 2.5.0 → 3.0.0-beta.0

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 (27) hide show
  1. package/.nyc_output/{3912b392-2912-48cc-9cca-bf322bf0d4e6.json → 0a7e2ebb-5cd8-42e1-8a75-1a844a599cb3.json} +0 -0
  2. package/.nyc_output/{73434d66-94ab-46e8-a516-e2fb6d961625.json → 1792cc95-23bc-4475-8a0a-5349fa6ea252.json} +0 -0
  3. package/.nyc_output/{81517a6e-3da5-4c5a-85fb-c3782bc44a31.json → 23b4d867-eb11-4139-958c-db9fba067b6b.json} +0 -0
  4. package/.nyc_output/{90c0d905-7a53-48a0-9c22-a39b1b831857.json → 480921e8-42bb-45b3-a743-dc9866e1335b.json} +0 -0
  5. package/.nyc_output/{c8f28bb3-0364-45d6-858b-7fe760a39c33.json → db445aca-7b0a-4fbd-b378-8f81807219e8.json} +0 -0
  6. package/.nyc_output/processinfo/{3912b392-2912-48cc-9cca-bf322bf0d4e6.json → 0a7e2ebb-5cd8-42e1-8a75-1a844a599cb3.json} +1 -1
  7. package/.nyc_output/processinfo/{73434d66-94ab-46e8-a516-e2fb6d961625.json → 1792cc95-23bc-4475-8a0a-5349fa6ea252.json} +1 -1
  8. package/.nyc_output/processinfo/{81517a6e-3da5-4c5a-85fb-c3782bc44a31.json → 23b4d867-eb11-4139-958c-db9fba067b6b.json} +1 -1
  9. package/.nyc_output/processinfo/{c8f28bb3-0364-45d6-858b-7fe760a39c33.json → 480921e8-42bb-45b3-a743-dc9866e1335b.json} +1 -1
  10. package/.nyc_output/processinfo/db445aca-7b0a-4fbd-b378-8f81807219e8.json +1 -0
  11. package/.nyc_output/processinfo/index.json +1 -1
  12. package/hugo-renderer/hugo_renderer.wasm +0 -0
  13. package/hugo-renderer/main.go +14 -0
  14. package/hugo-renderer/tpl/bookshop_engine/bookshop_func_importer.go +3 -2
  15. package/hugo-renderer/tpl/bookshop_library/bookshop_components.go +17 -2
  16. package/hugo-renderer/tpl/bookshop_library/bookshop_data.go +53 -0
  17. package/hugo-renderer/tpl/site/bookshop_site.go +59 -0
  18. package/hugo-renderer/tpl/site/init.go +41 -0
  19. package/hugo-renderer/tpl/transform/bookshop_unmarshal.go +39 -0
  20. package/hugo-renderer/tpl/transform/init.go +7 -0
  21. package/lib/engine.js +37 -6
  22. package/lib/hugoIdentifierParser.js +1 -1
  23. package/lib/hugoIdentifierParser.test.js +19 -0
  24. package/lib/translateTextTemplate.js +56 -29
  25. package/lib/translateTextTemplate.test.js +63 -4
  26. package/package.json +2 -2
  27. package/.nyc_output/processinfo/90c0d905-7a53-48a0-9c22-a39b1b831857.json +0 -1
@@ -1 +1 @@
1
- {"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","pid":36200,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1645506759846,"ppid":36197,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/3912b392-2912-48cc-9cca-bf322bf0d4e6.json","externalId":"","uuid":"3912b392-2912-48cc-9cca-bf322bf0d4e6","files":[]}
1
+ {"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","pid":41226,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1648442969710,"ppid":41179,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/0a7e2ebb-5cd8-42e1-8a75-1a844a599cb3.json","externalId":"","uuid":"0a7e2ebb-5cd8-42e1-8a75-1a844a599cb3","files":[]}
@@ -1 +1 @@
1
- {"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","pid":36198,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1645506759839,"ppid":36197,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/73434d66-94ab-46e8-a516-e2fb6d961625.json","externalId":"","uuid":"73434d66-94ab-46e8-a516-e2fb6d961625","files":[]}
1
+ {"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","pid":41228,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1648442969727,"ppid":41179,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/1792cc95-23bc-4475-8a0a-5349fa6ea252.json","externalId":"","uuid":"1792cc95-23bc-4475-8a0a-5349fa6ea252","files":[]}
@@ -1 +1 @@
1
- {"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","pid":36201,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1645506759852,"ppid":36197,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/81517a6e-3da5-4c5a-85fb-c3782bc44a31.json","externalId":"","uuid":"81517a6e-3da5-4c5a-85fb-c3782bc44a31","files":[]}
1
+ {"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","pid":41225,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1648442969705,"ppid":41179,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/23b4d867-eb11-4139-958c-db9fba067b6b.json","externalId":"","uuid":"23b4d867-eb11-4139-958c-db9fba067b6b","files":[]}
@@ -1 +1 @@
1
- {"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","pid":36199,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1645506759846,"ppid":36197,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/c8f28bb3-0364-45d6-858b-7fe760a39c33.json","externalId":"","uuid":"c8f28bb3-0364-45d6-858b-7fe760a39c33","files":[]}
1
+ {"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","pid":41227,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1648442969715,"ppid":41179,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/480921e8-42bb-45b3-a743-dc9866e1335b.json","externalId":"","uuid":"480921e8-42bb-45b3-a743-dc9866e1335b","files":[]}
@@ -0,0 +1 @@
1
+ {"parent":null,"pid":41179,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/cli.js","-v"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1648442969247,"ppid":41160,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/db445aca-7b0a-4fbd-b378-8f81807219e8.json","externalId":"","uuid":"db445aca-7b0a-4fbd-b378-8f81807219e8","files":[]}
@@ -1 +1 @@
1
- {"processes":{"3912b392-2912-48cc-9cca-bf322bf0d4e6":{"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","children":[]},"73434d66-94ab-46e8-a516-e2fb6d961625":{"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","children":[]},"81517a6e-3da5-4c5a-85fb-c3782bc44a31":{"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","children":[]},"90c0d905-7a53-48a0-9c22-a39b1b831857":{"parent":null,"children":["3912b392-2912-48cc-9cca-bf322bf0d4e6","73434d66-94ab-46e8-a516-e2fb6d961625","81517a6e-3da5-4c5a-85fb-c3782bc44a31","c8f28bb3-0364-45d6-858b-7fe760a39c33"]},"c8f28bb3-0364-45d6-858b-7fe760a39c33":{"parent":"90c0d905-7a53-48a0-9c22-a39b1b831857","children":[]}},"files":{},"externalIds":{}}
1
+ {"processes":{"0a7e2ebb-5cd8-42e1-8a75-1a844a599cb3":{"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","children":[]},"1792cc95-23bc-4475-8a0a-5349fa6ea252":{"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","children":[]},"23b4d867-eb11-4139-958c-db9fba067b6b":{"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","children":[]},"480921e8-42bb-45b3-a743-dc9866e1335b":{"parent":"db445aca-7b0a-4fbd-b378-8f81807219e8","children":[]},"db445aca-7b0a-4fbd-b378-8f81807219e8":{"parent":null,"children":["0a7e2ebb-5cd8-42e1-8a75-1a844a599cb3","1792cc95-23bc-4475-8a0a-5349fa6ea252","23b4d867-eb11-4139-958c-db9fba067b6b","480921e8-42bb-45b3-a743-dc9866e1335b"]}},"files":{},"externalIds":{}}
Binary file
@@ -11,6 +11,8 @@ func main() {
11
11
  c := make(chan struct{}, 0)
12
12
  js.Global().Set("renderHugo", js.FuncOf(renderHugo))
13
13
  js.Global().Set("loadHugoBookshopPartials", js.FuncOf(loadHugoBookshopPartials))
14
+ js.Global().Set("loadHugoBookshopData", js.FuncOf(loadHugoBookshopData))
15
+ js.Global().Set("loadHugoBookshopMeta", js.FuncOf(loadHugoBookshopMeta))
14
16
  <-c
15
17
  }
16
18
 
@@ -26,3 +28,15 @@ func loadHugoBookshopPartials(this js.Value, args []js.Value) interface{} {
26
28
 
27
29
  return library.LoadHugoBookshopPartials(bookshopPartials)
28
30
  }
31
+
32
+ func loadHugoBookshopData(this js.Value, args []js.Value) interface{} {
33
+ bookshopData := args[0].String()
34
+
35
+ return library.LoadHugoBookshopData(bookshopData)
36
+ }
37
+
38
+ func loadHugoBookshopMeta(this js.Value, args []js.Value) interface{} {
39
+ bookshopMeta := args[0].String()
40
+
41
+ return library.LoadHugoBookshopMeta(bookshopMeta)
42
+ }
@@ -24,9 +24,10 @@ import (
24
24
  _ "hugo-renderer/tpl/reflect"
25
25
 
26
26
  // _ "hugo-renderer/tpl/resources" // ——————————— ⏭️ NTBI: Bookshop components won't support resources
27
- _ "hugo-renderer/tpl/safe" // ——————————————————— 🥴 TODO: `SanitizeURL` NYI — helpers require is too large
28
- // _ "hugo-renderer/tpl/site" // ———————————————— TODO: Should this be stubbed out ??
27
+ _ "hugo-renderer/tpl/safe" // ———————————————— 🥴 TODO: `SanitizeURL` NYI — helpers require is too large
28
+ _ "hugo-renderer/tpl/site" // ———————————————— 🥴 TODO: Partially stubbing out site variables. WIP
29
29
  _ "hugo-renderer/tpl/strings" // ———————————————— 🥴 TODO: Only the "Go" title formatting is supported
30
+
30
31
  // _ "hugo-renderer/tpl/templates" // ——————————— ❗ TODO: Maybe a rabbit hole
31
32
  // _ "hugo-renderer/tpl/time" // ———————————————— ❗ TODO: This relies on lang stuff that is thus far excluded
32
33
  _ "hugo-renderer/tpl/transform" // —————————————— 🥴 TODO: Highlight, unmarshal, commonmark compat
@@ -86,14 +86,24 @@ func UnwrapBookshopComponent(context interface{}) (string, interface{}) {
86
86
  key := fmt.Sprintf("components/%s/%s.hugo.html", component.(string), component.(string))
87
87
  return key, context
88
88
  }
89
+ return "err_no_bookshop_name_key", context
89
90
  }
90
91
  if componentData, ok := context.([]interface{}); ok {
91
92
  if component, ok := componentData[0].(string); ok {
92
93
  key := fmt.Sprintf("components/%s/%s.hugo.html", component, component)
93
94
  return key, componentData[1]
94
95
  }
96
+ return "err_slice_zero_not_string", context
95
97
  }
96
- return "err_no_bookshop_name", context
98
+ if componentData, ok := context.([]string); ok {
99
+ key := fmt.Sprintf("components/%s/%s.hugo.html", componentData[0], componentData[0])
100
+ return key, componentData[1]
101
+ }
102
+ if componentName, ok := context.(string); ok {
103
+ key := fmt.Sprintf("components/%s/%s.hugo.html", componentName, componentName)
104
+ return key, nil
105
+ }
106
+ return "err_not_map_slice_or_string", context
97
107
  }
98
108
 
99
109
  func UnwrapBookshopPartial(context interface{}) (string, interface{}) {
@@ -102,6 +112,11 @@ func UnwrapBookshopPartial(context interface{}) (string, interface{}) {
102
112
  key := fmt.Sprintf("shared/hugo/%s.hugo.html", partial)
103
113
  return key, partialData[1]
104
114
  }
115
+ return "err_slice_zero_not_string", context
116
+ }
117
+ if partialName, ok := context.(string); ok {
118
+ key := fmt.Sprintf("shared/hugo/%s.hugo.html", partialName)
119
+ return key, nil
105
120
  }
106
- return "err_no_bookshop_name", context
121
+ return "err_not_slice_or_string", context
107
122
  }
@@ -0,0 +1,53 @@
1
+ package bookshop_library
2
+
3
+ import (
4
+ "bytes"
5
+ "encoding/json"
6
+ "fmt"
7
+ )
8
+
9
+ type bookshopData struct {
10
+ Data map[string]interface{} `json:"data"`
11
+ }
12
+
13
+ var bookshopDataStorage bookshopData
14
+
15
+ // loadHugoBookshopData takes any data that the @bookshop/hugo-engine
16
+ // was given from info.json and stashes it all away
17
+ // on this side of the wasm boundary, for the site
18
+ // function to use.
19
+ func LoadHugoBookshopData(data string) interface{} {
20
+ err := json.Unmarshal([]byte(data), &bookshopDataStorage)
21
+ if err != nil {
22
+ buf := bytes.NewBufferString(fmt.Sprintf("bad json unmarshal: %s", err.Error()))
23
+ return buf.String()
24
+ }
25
+
26
+ buf := bytes.NewBufferString("loaded Bookshop site data")
27
+ return buf.String()
28
+ }
29
+
30
+ func RetrieveHugoBookshopData() *bookshopData {
31
+ return &bookshopDataStorage
32
+ }
33
+
34
+ var bookshopMetaStorage map[string]interface{}
35
+
36
+ // loadHugoBookshopMeta takes any data that hugo/bookshop
37
+ // injected into the template and stashes it all away
38
+ // on this side of the wasm boundary, for the site
39
+ // function to use.
40
+ func LoadHugoBookshopMeta(data string) interface{} {
41
+ err := json.Unmarshal([]byte(data), &bookshopMetaStorage)
42
+ if err != nil {
43
+ buf := bytes.NewBufferString(fmt.Sprintf("bad json unmarshal: %s", err.Error()))
44
+ return buf.String()
45
+ }
46
+
47
+ buf := bytes.NewBufferString("loaded Bookshop site data")
48
+ return buf.String()
49
+ }
50
+
51
+ func RetrieveHugoBookshopMeta() map[string]interface{} {
52
+ return bookshopMetaStorage
53
+ }
@@ -0,0 +1,59 @@
1
+ // Copyright 2017 The Hugo Authors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+
14
+ // Package site stubs out some of the Hugo site functions for use in Bookshop live editing.
15
+ package site
16
+
17
+ import (
18
+ "hugo-renderer/deps"
19
+ library "hugo-renderer/tpl/bookshop_library"
20
+ )
21
+
22
+ func New(deps *deps.Deps) *Namespace {
23
+ return &Namespace{
24
+ deps: deps,
25
+ }
26
+ }
27
+
28
+ type Namespace struct {
29
+ deps *deps.Deps
30
+ }
31
+
32
+ // Data returns any data that was present in the _cloudcannon/info.json
33
+ // This will require `data_config: true` in the site cloudcannon.config.yml
34
+ func (ns *Namespace) Data() (map[string]interface{}, error) {
35
+ data := library.RetrieveHugoBookshopData()
36
+
37
+ return data.Data, nil
38
+ }
39
+
40
+ // site.Title should have been stashed inside a Bookshop meta comment
41
+ func (ns *Namespace) Title() (interface{}, error) {
42
+ meta := library.RetrieveHugoBookshopMeta()
43
+
44
+ return meta["title"], nil
45
+ }
46
+
47
+ // site.Copyright should have been stashed inside a Bookshop meta comment
48
+ func (ns *Namespace) Copyright() (interface{}, error) {
49
+ meta := library.RetrieveHugoBookshopMeta()
50
+
51
+ return meta["copyright"], nil
52
+ }
53
+
54
+ // site.BaseURL should have been stashed inside a Bookshop meta comment
55
+ func (ns *Namespace) BaseURL() (interface{}, error) {
56
+ meta := library.RetrieveHugoBookshopMeta()
57
+
58
+ return meta["baseurl"], nil
59
+ }
@@ -0,0 +1,41 @@
1
+ // Copyright 2017 The Hugo Authors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+
14
+ package site
15
+
16
+ import (
17
+ "hugo-renderer/deps"
18
+ "hugo-renderer/tpl/internal"
19
+ )
20
+
21
+ const name = "site"
22
+
23
+ func init() {
24
+ f := func(d *deps.Deps) *internal.TemplateFuncsNamespace {
25
+ ctx := New(d)
26
+
27
+ ns := &internal.TemplateFuncsNamespace{
28
+ Name: name,
29
+ Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
30
+ }
31
+
32
+ ns.AddMethodMapping(ctx.Data,
33
+ []string{},
34
+ [][2]string{},
35
+ )
36
+
37
+ return ns
38
+ }
39
+
40
+ internal.AddTemplateFuncsNamespace(f)
41
+ }
@@ -0,0 +1,39 @@
1
+ // Copyright 2019 The Hugo Authors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+
14
+ package transform
15
+
16
+ import (
17
+ "encoding/json"
18
+
19
+ "github.com/pkg/errors"
20
+ )
21
+
22
+ // Unmarshal unmarshals the data given, which can be either a string, json.RawMessage
23
+ // or a Resource. Supported formats are JSON, TOML, YAML, and CSV.
24
+ // You can optionally provide an options map as the first argument.
25
+ func (ns *Namespace) BookshopUnmarshal(args ...interface{}) (interface{}, error) {
26
+ if len(args) != 1 {
27
+ return nil, errors.New("Bookshop unmarshal takes 1 argument")
28
+ }
29
+
30
+ var data interface{}
31
+
32
+ if r, ok := args[0].(string); ok {
33
+ if err := json.Unmarshal([]byte(r), &data); err != nil {
34
+ return nil, err
35
+ }
36
+ return data, nil
37
+ }
38
+ return nil, errors.New("Needed a string")
39
+ }
@@ -99,6 +99,13 @@ func init() {
99
99
 
100
100
  // Bookshop: unmarshal has been removed (for now) due to tendrils
101
101
 
102
+ ns.AddMethodMapping(ctx.BookshopUnmarshal,
103
+ []string{"bookshopunmarshal"},
104
+ [][2]string{
105
+ {`{{ "{ hello = \"Hello World\" }" | transform.BookshopUnmarshal }}`, "map[hello:Hello World]"},
106
+ },
107
+ )
108
+
102
109
  return ns
103
110
  }
104
111
 
package/lib/engine.js CHANGED
@@ -31,11 +31,12 @@ export class Engine {
31
31
  }
32
32
 
33
33
  async initializeHugo() {
34
+ const useLocalHugo = window.CloudCannon?.isMocked || /localhost|127\.0\.0\.1/i.test(window.location.host);
34
35
  // When this script is run locally, the hugo wasm is loaded as binary rather than output as a file.
35
36
  if (hugoWasm?.constructor === Uint8Array) {
36
37
  await this.initializeInlineHugo();
37
38
  } else {
38
- if (window.CloudCannon?.isMocked) {
39
+ if (useLocalHugo) {
39
40
  await this.initializeLocalHugo();
40
41
  } else {
41
42
  await this.initializeRemoteHugo();
@@ -73,7 +74,7 @@ export class Engine {
73
74
 
74
75
  async initializeLocalHugo() {
75
76
  const go = new Go();
76
- const wasmOrigin = this.origin.replace(/\/[^\.\/]+\.js$/, hugoWasm.replace(/^\./, ''));
77
+ const wasmOrigin = this.origin.replace(/\/[^\.\/]+\.js/, hugoWasm.replace(/^\./, ''));
77
78
  const response = await fetch(wasmOrigin);
78
79
  const buffer = await response.arrayBuffer();
79
80
  const result = await WebAssembly.instantiate(buffer, go.importObject);
@@ -119,8 +120,25 @@ export class Engine {
119
120
  };
120
121
  }
121
122
 
122
- async render(target, name, props, globals) {
123
- while (!window.renderHugo) await sleep(10);
123
+ async storeMeta(meta = {}) {
124
+ while (!window.loadHugoBookshopMeta) {
125
+ await sleep(100);
126
+ };
127
+ window.loadHugoBookshopMeta(JSON.stringify(meta));
128
+ }
129
+
130
+ async storeInfo(info = {}) {
131
+ while (!window.loadHugoBookshopData) {
132
+ await sleep(100);
133
+ };
134
+ window.loadHugoBookshopData(JSON.stringify(info));
135
+ }
136
+
137
+ async render(target, name, props, globals, logger) {
138
+ while (!window.renderHugo) {
139
+ logger?.log?.(`Waiting for the Hugo WASM to be available...`);
140
+ await sleep(100);
141
+ };
124
142
 
125
143
  let source = this.getComponent(name);
126
144
  // TODO: Remove the below check and update the live comments to denote shared
@@ -129,8 +147,10 @@ export class Engine {
129
147
  console.warn(`[hugo-engine] No component found for ${name}`);
130
148
  return "";
131
149
  }
150
+ logger?.log?.(`Going to render ${name}`);
132
151
  // TODO: this template already exists on the other side of the wasm bounary
133
152
  source = translateTextTemplate(source, {});
153
+ logger?.log?.(`Rewritten the template for ${name}`);
134
154
  if (!globals || typeof globals !== "object") globals = {};
135
155
  props = { ...globals, ...props };
136
156
 
@@ -138,8 +158,10 @@ export class Engine {
138
158
  if (props["."]) props = props["."];
139
159
  const output = window.renderHugo(source, JSON.stringify(props));
140
160
  if (/BKSHERR/.test(output)) {
161
+ logger?.log?.(`Failed to render ${output}`);
141
162
  console.error(output);
142
163
  } else {
164
+ logger?.log?.(`Rendered ${name}`);
143
165
  target.innerHTML = output;
144
166
  }
145
167
  }
@@ -162,13 +184,22 @@ export class Engine {
162
184
  return `index (${obj}) ${index}`;
163
185
  })
164
186
 
165
- const eval_str = `{{ jsonify (${str}) }}`;
187
+ const assignments = Object.entries(props_obj).filter(([key]) => key.startsWith('$')).map(([key, value]) => {
188
+ if (Array.isArray(value)) {
189
+ return `{{ ${key} := index ( \`{"a": ${JSON.stringify(value)}}\` | transform.BookshopUnmarshal ) "a" }}`
190
+ } else if (typeof value === 'object') {
191
+ return `{{ ${key} := \`${JSON.stringify(value)}\` | transform.BookshopUnmarshal }}`
192
+ } else {
193
+ return `{{ ${key} := ${JSON.stringify(value)} }}`
194
+ }
195
+ }).join('');
196
+ const eval_str = `${assignments}{{ jsonify (${str}) }}`;
166
197
  const output = window.renderHugo(eval_str, JSON.stringify(props_obj));
167
198
 
168
199
  try {
169
200
  return JSON.parse(output);
170
201
  } catch (e) {
171
- console.error(`Error evaluating \`${str}\` in the Hugo engine`, output);
202
+ console.warn(`Error evaluating \`${str}\` in the Hugo engine`, output);
172
203
  return null;
173
204
  }
174
205
  }
@@ -1,7 +1,7 @@
1
1
  const TOKENS = {
2
2
  DELIM: /"|'|`/,
3
3
  ESCAPE: /\\/,
4
- SPACE: /\s/,
4
+ SPACE: /\s|\r|\n/,
5
5
  INSCOPE: /\(/,
6
6
  OUTSCOPE: /\)/,
7
7
  SCOPE: /\./,
@@ -88,4 +88,23 @@ test(`Converts a dot index into a JS object property`, async t => {
88
88
  ident = `(index . 1234)`;
89
89
  output = (new IdentifierParser(ident)).build();
90
90
  t.deepEqual(output, `1234`);
91
+ });
92
+
93
+ test(`Multiline dicts and slices`, async t => {
94
+ const ident = `(dict
95
+ "contents"
96
+ (slice 1 "2"
97
+ (dict
98
+ "a" .Params.b)
99
+ ) "len" (
100
+ len
101
+ .some_array
102
+ ))`;
103
+ const output = (new IdentifierParser(ident)).build();
104
+ t.deepEqual(output, {
105
+ "contents": ["1", `"2"`, {
106
+ "a": "Params.b"
107
+ }],
108
+ "len": `(\n len\n .some_array\n)`
109
+ });
91
110
  });
@@ -1,17 +1,26 @@
1
1
  import { Tokenizer } from 'liquidjs';
2
2
 
3
+ // Homebrewed pretty-regex writer
3
4
  const tokens = {
4
- END: /{{\s*end\s*}}/,
5
- BEGIN: /{{\s*(if)/,
6
- BEGIN_SCOPED: /{{\s*(range|with|define|block|template)/,
7
- LOOP: /{{\s*range\s+(.+?)\s*}}/,
8
- INDEX_LOOP: /{{\s*range\s+(\$.+), \$.+ := (.+?)\s*}}/,
9
- ASSIGN: /{{\s*(\$\S+)\s+:=\s+(.+?)\s*}}/,
10
- WITH: /{{\s*with\s+(.+?)\s*}}/,
11
- BOOKSHOP: /{{\s*partial\s+"bookshop"\s+\(\s*slice\s+"(.+?)" (.+?)\s*\)\s*}}/,
12
- BOOKSHOP_SCOPED: /{{\s*partial\s+"bookshop"\s+\(?\s*\.\s*\)?\s*}}/,
5
+ END: `{{ end }}`,
6
+ BEGIN: `{{ (if)`,
7
+ BEGIN_SCOPED: `{{ (range|with|define|block|template)`,
8
+ LOOP: `{{ range () }}`,
9
+ INDEX_LOOP: `{{ range (\\$.+), \\$.+ := () }}`,
10
+ ASSIGN: `{{ (\\$\\S+) := () }}`,
11
+ REASSIGN: `{{ (\\$\\S+) = () }}`,
12
+ WITH: `{{ with () }}`,
13
+ BOOKSHOP: `{{ partial "bookshop" \\( slice "()" () \\) }}`,
14
+ BOOKSHOP_SCOPED: `{{ partial "bookshop" \\(? \\. \\)? }}`,
13
15
  }
14
16
 
17
+ const TOKENS = {};
18
+ Object.entries(tokens).forEach(([name, r]) => {
19
+ TOKENS[name] = new RegExp(r
20
+ .replace(/\(\)/g, '([\\S\\s]+?)') // Empty capturing group defaults to lazy multiline capture
21
+ .replace(/ /g, '[\\n\\r\\s]+') // Two spaces actually means one or more blanks
22
+ .replace(/ /g, '[\\n\\r\\s]*')); // One space means zero or more blanks
23
+ });
15
24
  /**
16
25
  * Parse a go text/template using the liquidjs parser
17
26
  * that we already have in the bundle.
@@ -25,44 +34,56 @@ const rewriteTag = function (token, src, endTags, liveMarkup) {
25
34
 
26
35
  // Skip non-value tags
27
36
  if (token.kind !== 8) return outputToken;
28
- if (tokens.END.test(raw)) {
37
+ if (TOKENS.END.test(raw)) {
29
38
  endTags.push(outputToken);
30
39
  return outputToken;
31
40
  }
32
41
 
33
- if (tokens.BEGIN.test(raw)) {
42
+ if (TOKENS.BEGIN.test(raw)) {
34
43
  endTags.pop();
35
44
  }
36
45
 
37
- if (tokens.BEGIN_SCOPED.test(raw)) {
46
+ if (TOKENS.BEGIN_SCOPED.test(raw)) {
38
47
  outputToken.text = `${outputToken.text}{{ \`<!--bookshop-live stack-->\` | safeHTML }}`;
39
48
 
40
49
  let matchingEnd = endTags.pop();
41
50
  matchingEnd.text = `{{ \`<!--bookshop-live unstack-->\` | safeHTML }}${matchingEnd.text}`;
42
51
  }
43
52
 
44
- if (liveMarkup && tokens.INDEX_LOOP.test(raw)) {
45
- let [, index_variable, iterator] = raw.match(tokens.INDEX_LOOP);
53
+ if (liveMarkup && TOKENS.INDEX_LOOP.test(raw)) {
54
+ let [, index_variable, iterator] = raw.match(TOKENS.INDEX_LOOP);
55
+ const r = required_wrapper_hugo_func(iterator);
46
56
  outputToken.text = [`${outputToken.text}`,
47
- `{{ (printf \`<!--bookshop-live context(.: (index (${iterator}) %d))-->\` ${index_variable}) | safeHTML }}`
57
+ `{{${r[0]} (printf \`<!--bookshop-live context(.: (index (${tidy(iterator)}) %v))-->\` (jsonify ${index_variable}))${r[1]} | safeHTML }}`
48
58
  ].join('')
49
- } else if (liveMarkup && tokens.LOOP.test(raw)) {
50
- let [, iterator] = raw.match(tokens.LOOP);
51
- outputToken.text = [`{{ $bookshop__live__iterator := 0 }}`,
59
+ } else if (liveMarkup && TOKENS.LOOP.test(raw)) {
60
+ let [, iterator] = raw.match(TOKENS.LOOP);
61
+ const r = required_wrapper_hugo_func(iterator);
62
+ outputToken.text = [`{{ $bookshop__live__iterator__keys := (slice) }}`,
63
+ `{{ range $i, $e := (${tidy(iterator)}) }}{{ $bookshop__live__iterator__keys = $bookshop__live__iterator__keys | append $i }}{{ end }}`,
64
+ `{{ $bookshop__live__iterator := 0 }}`,
52
65
  `${outputToken.text}`,
53
- `{{ (printf \`<!--bookshop-live context(.: (index (${iterator}) %d))-->\` $bookshop__live__iterator) | safeHTML }}`,
66
+ `{{ $bookshop__live__iterator__key := (index ($bookshop__live__iterator__keys) $bookshop__live__iterator) }}`,
67
+ `{{${r[0]} (printf \`<!--bookshop-live context(.: (index (${tidy(iterator)}) %v))-->\` (jsonify $bookshop__live__iterator__key))${r[1]} | safeHTML }}`,
54
68
  `{{ $bookshop__live__iterator = (add $bookshop__live__iterator 1) }}`
55
69
  ].join('')
56
- } else if (liveMarkup && tokens.ASSIGN.test(raw)) {
57
- let [, identifier, value] = raw.match(tokens.ASSIGN);
58
- outputToken.text = `${outputToken.text}{{ \`<!--bookshop-live context(${identifier}: (${value}))-->\` | safeHTML }}`
59
- } else if (liveMarkup && tokens.WITH.test(raw)) {
60
- let [, value] = raw.match(tokens.WITH);
61
- outputToken.text = `${outputToken.text}{{ \`<!--bookshop-live context(.: (${value}))-->\` | safeHTML }}`
62
- } else if (liveMarkup && tokens.BOOKSHOP.test(raw)) {
63
- let [, name, params] = raw.match(tokens.BOOKSHOP);
64
- outputToken.text = `{{ \`<!--bookshop-live name(${name}) params(.: (${params}))-->\` | safeHTML }}${outputToken.text}{{ \`<!--bookshop-live end-->\` | safeHTML }}`
65
- } else if (liveMarkup && tokens.BOOKSHOP_SCOPED.test(raw)) {
70
+ } else if (liveMarkup && TOKENS.ASSIGN.test(raw)) {
71
+ let [, identifier, value] = raw.match(TOKENS.ASSIGN);
72
+ const r = required_wrapper_hugo_func(value);
73
+ outputToken.text = `${outputToken.text}{{${r[0]} \`<!--bookshop-live context(${identifier}: (${tidy(value)}))-->\`${r[1]} | safeHTML }}`
74
+ } else if (liveMarkup && TOKENS.REASSIGN.test(raw)) {
75
+ let [, identifier, value] = raw.match(TOKENS.REASSIGN);
76
+ const r = required_wrapper_hugo_func(value);
77
+ outputToken.text = `${outputToken.text}{{${r[0]} \`<!--bookshop-live reassign(${identifier}: (${tidy(value)}))-->\`${r[1]} | safeHTML }}`
78
+ } else if (liveMarkup && TOKENS.WITH.test(raw)) {
79
+ let [, value] = raw.match(TOKENS.WITH);
80
+ const r = required_wrapper_hugo_func(value);
81
+ outputToken.text = `${outputToken.text}{{${r[0]} \`<!--bookshop-live context(.: (${tidy(value)}))-->\`${r[1]} | safeHTML }}`
82
+ } else if (liveMarkup && TOKENS.BOOKSHOP.test(raw)) {
83
+ let [, name, params] = raw.match(TOKENS.BOOKSHOP);
84
+ const r = required_wrapper_hugo_func(params);
85
+ outputToken.text = `{{${r[0]} \`<!--bookshop-live name(${name}) params(.: (${tidy(params)}))-->\`${r[1]} | safeHTML }}${outputToken.text}{{ \`<!--bookshop-live end-->\` | safeHTML }}`
86
+ } else if (liveMarkup && TOKENS.BOOKSHOP_SCOPED.test(raw)) {
66
87
  outputToken.text = [`{{ if reflect.IsSlice . }}{{ (printf \`<!--bookshop-live name(%s) params(.: .)-->\` (index . 0)) | safeHTML }}`,
67
88
  `{{- else if reflect.IsMap . -}}{{ (printf \`<!--bookshop-live name(%s) params(.: .)-->\` ._bookshop_name) | safeHTML }}{{ end }}`,
68
89
  `${outputToken.text}`,
@@ -73,6 +94,12 @@ const rewriteTag = function (token, src, endTags, liveMarkup) {
73
94
  return outputToken;
74
95
  }
75
96
 
97
+ // limit comments to one line & escape backticks to something we undo later
98
+ const tidy = val => val.replace(/[\r\n]/g, ' ').replace(/`/g, 'BKSH_BACKTICK');
99
+
100
+ // The replace function we need to add to undo the backtick tidy above
101
+ const required_wrapper_hugo_func = val => /`/.test(val) ? [` replace`, ` "BKSH_BACKTICK" "\`"`] : [``, ``];
102
+
76
103
  export default function (text, opts) {
77
104
  opts = {
78
105
  liveMarkup: true,
@@ -36,6 +36,10 @@ test("add live markup to assigns", t => {
36
36
  input = `{{ $a := .b | chomp }}`;
37
37
  expected = `{{ $a := .b | chomp }}{{ \`<!--bookshop-live context($a: (.b | chomp))-->\` | safeHTML }}`;
38
38
  t.is(translateTextTemplate(input, {}), expected);
39
+
40
+ input = `{{ $a = .b }}`;
41
+ expected = `{{ $a = .b }}{{ \`<!--bookshop-live reassign($a: (.b))-->\` | safeHTML }}`;
42
+ t.is(translateTextTemplate(input, {}), expected);
39
43
  });
40
44
 
41
45
  test("add live markup to withs", t => {
@@ -52,10 +56,13 @@ test("add live markup to withs", t => {
52
56
 
53
57
  test("add live markup to loops", t => {
54
58
  const input = `{{ range .items }}<p>{{ . }}</p>{{ end }}`;
55
- const expected = [`{{ $bookshop__live__iterator := 0 }}`,
59
+ const expected = [`{{ $bookshop__live__iterator__keys := (slice) }}`,
60
+ `{{ range $i, $e := (.items) }}{{ $bookshop__live__iterator__keys = $bookshop__live__iterator__keys | append $i }}{{ end }}`,
61
+ `{{ $bookshop__live__iterator := 0 }}`,
56
62
  `{{ range .items }}`,
57
63
  `{{ \`<!--bookshop-live stack-->\` | safeHTML }}`,
58
- `{{ (printf \`<!--bookshop-live context(.: (index (.items) %d))-->\` $bookshop__live__iterator) | safeHTML }}`,
64
+ `{{ $bookshop__live__iterator__key := (index ($bookshop__live__iterator__keys) $bookshop__live__iterator) }}`,
65
+ `{{ (printf \`<!--bookshop-live context(.: (index (.items) %v))-->\` (jsonify $bookshop__live__iterator__key)) | safeHTML }}`,
59
66
  `{{ $bookshop__live__iterator = (add $bookshop__live__iterator 1) }}`,
60
67
  `<p>{{ . }}</p>`,
61
68
  `{{ \`<!--bookshop-live unstack-->\` | safeHTML }}`,
@@ -68,7 +75,7 @@ test("add live markup to loops with iterators", t => {
68
75
  const input = `{{range $loop_index, $element := .columns}}<p>{{$element}}</p>{{ end }}`;
69
76
  const expected = [`{{range $loop_index, $element := .columns}}`,
70
77
  `{{ \`<!--bookshop-live stack-->\` | safeHTML }}`,
71
- `{{ (printf \`<!--bookshop-live context(.: (index (.columns) %d))-->\` $loop_index) | safeHTML }}`,
78
+ `{{ (printf \`<!--bookshop-live context(.: (index (.columns) %v))-->\` (jsonify $loop_index)) | safeHTML }}`,
72
79
  `<p>{{$element}}</p>`,
73
80
  `{{ \`<!--bookshop-live unstack-->\` | safeHTML }}`,
74
81
  `{{ end }}`
@@ -76,6 +83,12 @@ test("add live markup to loops with iterators", t => {
76
83
  t.is(translateTextTemplate(input, {}), expected);
77
84
  });
78
85
 
86
+ test("escape backticks in values", t => {
87
+ let input = `{{ $a := "hi\`:)" }}`;
88
+ let expected = `{{ $a := "hi\`:)" }}{{ replace \`<!--bookshop-live context($a: ("hiBKSH_BACKTICK:)"))-->\` "BKSH_BACKTICK" "\`" | safeHTML }}`;
89
+ t.is(translateTextTemplate(input, {}), expected);
90
+ });
91
+
79
92
  test("add live markup to complex end structures", t => {
80
93
  const input = `
81
94
  {{ range .items }}
@@ -94,7 +107,7 @@ test("add live markup to complex end structures", t => {
94
107
 
95
108
  {{ end }}`;
96
109
  const expected = `
97
- {{ $bookshop__live__iterator := 0 }}{{ range .items }}{{ \`<!--bookshop-live stack-->\` | safeHTML }}{{ (printf \`<!--bookshop-live context(.: (index (.items) %d))-->\` $bookshop__live__iterator) | safeHTML }}{{ $bookshop__live__iterator = (add $bookshop__live__iterator 1) }}
110
+ {{ $bookshop__live__iterator__keys := (slice) }}{{ range $i, $e := (.items) }}{{ $bookshop__live__iterator__keys = $bookshop__live__iterator__keys | append $i }}{{ end }}{{ $bookshop__live__iterator := 0 }}{{ range .items }}{{ \`<!--bookshop-live stack-->\` | safeHTML }}{{ $bookshop__live__iterator__key := (index ($bookshop__live__iterator__keys) $bookshop__live__iterator) }}{{ (printf \`<!--bookshop-live context(.: (index (.items) %v))-->\` (jsonify $bookshop__live__iterator__key)) | safeHTML }}{{ $bookshop__live__iterator = (add $bookshop__live__iterator 1) }}
98
111
 
99
112
  {{with .text}}{{ \`<!--bookshop-live stack-->\` | safeHTML }}{{ \`<!--bookshop-live context(.: (.text))-->\` | safeHTML }}
100
113
  <p>{{ . }}</p>
@@ -108,6 +121,52 @@ test("add live markup to complex end structures", t => {
108
121
  {{ \`<!--bookshop-live unstack-->\` | safeHTML }}{{end}}
109
122
  {{ end }}
110
123
 
124
+ {{ \`<!--bookshop-live unstack-->\` | safeHTML }}{{ end }}`;
125
+ t.is(translateTextTemplate(input, {}), expected);
126
+ });
127
+
128
+ test("add live markup to complex components", t => {
129
+ const input = `
130
+ {{ $level := default 2 .level }}
131
+ {{ $level = string
132
+ $level }}
133
+ {{ $level_classes := dict
134
+ "1" "border-b py-8 text-4xl"
135
+ "2" "border-b py-6 text-3xl"
136
+ "3" "border-b py-4 text-2xl font-bold"
137
+ "4" "border-b text-xl font-bold"
138
+ }}
139
+ {{ $level_class := "lg" }}
140
+ {{ with index $level_classes $level }}
141
+ {{ $level_class = . }}
142
+ {{ end }}
143
+ {{ $open := printf \`<h%s class="%s">\` $level $level_class }}
144
+ {{ $close := printf \`</h%s>\` $level }}
145
+ {{ with .copy }}
146
+ {{ safeHTML $open }}
147
+ {{ markdownify . }} | bookshop
148
+ {{ safeHTML $close }}
149
+ {{ end }}`;
150
+ const expected = `
151
+ {{ $level := default 2 .level }}{{ \`<!--bookshop-live context($level: (default 2 .level))-->\` | safeHTML }}
152
+ {{ $level = string
153
+ $level }}{{ \`<!--bookshop-live reassign($level: (string $level))-->\` | safeHTML }}
154
+ {{ $level_classes := dict
155
+ "1" "border-b py-8 text-4xl"
156
+ "2" "border-b py-6 text-3xl"
157
+ "3" "border-b py-4 text-2xl font-bold"
158
+ "4" "border-b text-xl font-bold"
159
+ }}{{ \`<!--bookshop-live context($level_classes: (dict "1" "border-b py-8 text-4xl" "2" "border-b py-6 text-3xl" "3" "border-b py-4 text-2xl font-bold" "4" "border-b text-xl font-bold"))-->\` | safeHTML }}
160
+ {{ $level_class := "lg" }}{{ \`<!--bookshop-live context($level_class: ("lg"))-->\` | safeHTML }}
161
+ {{ with index $level_classes $level }}{{ \`<!--bookshop-live stack-->\` | safeHTML }}{{ \`<!--bookshop-live context(.: (index $level_classes $level))-->\` | safeHTML }}
162
+ {{ $level_class = . }}{{ \`<!--bookshop-live reassign($level_class: (.))-->\` | safeHTML }}
163
+ {{ \`<!--bookshop-live unstack-->\` | safeHTML }}{{ end }}
164
+ {{ $open := printf \`<h%s class="%s">\` $level $level_class }}{{ replace \`<!--bookshop-live context($open: (printf BKSH_BACKTICK<h%s class="%s">BKSH_BACKTICK $level $level_class))-->\` "BKSH_BACKTICK" "\`" | safeHTML }}
165
+ {{ $close := printf \`</h%s>\` $level }}{{ replace \`<!--bookshop-live context($close: (printf BKSH_BACKTICK</h%s>BKSH_BACKTICK $level))-->\` "BKSH_BACKTICK" "\`" | safeHTML }}
166
+ {{ with .copy }}{{ \`<!--bookshop-live stack-->\` | safeHTML }}{{ \`<!--bookshop-live context(.: (.copy))-->\` | safeHTML }}
167
+ {{ safeHTML $open }}
168
+ {{ markdownify . }} | bookshop
169
+ {{ safeHTML $close }}
111
170
  {{ \`<!--bookshop-live unstack-->\` | safeHTML }}{{ end }}`;
112
171
  t.is(translateTextTemplate(input, {}), expected);
113
172
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bookshop/hugo-engine",
3
3
  "packageManager": "yarn@3.0.0",
4
- "version": "2.5.0",
4
+ "version": "3.0.0-beta.0",
5
5
  "description": "Bookshop frontend Hugo renderer",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -29,7 +29,7 @@
29
29
  "nyc": "^15.1.0"
30
30
  },
31
31
  "dependencies": {
32
- "@bookshop/helpers": "2.5.0",
32
+ "@bookshop/helpers": "3.0.0-beta.0",
33
33
  "esbuild": "^0.13.10",
34
34
  "liquidjs": "9.28.0"
35
35
  },
@@ -1 +0,0 @@
1
- {"parent":null,"pid":36197,"argv":["/Users/liambigelow/.nvm/versions/node/v14.16.0/bin/node","/Users/liambigelow/Projects/CC/bookshop/javascript-modules/node_modules/ava/cli.js","-v"],"execArgv":[],"cwd":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine","time":1645506759370,"ppid":36196,"coverageFilename":"/Users/liambigelow/Projects/CC/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/90c0d905-7a53-48a0-9c22-a39b1b831857.json","externalId":"","uuid":"90c0d905-7a53-48a0-9c22-a39b1b831857","files":[]}