Skip to content

Commit

Permalink
Merge pull request #23 from nicholaswilde/fix-comments
Browse files Browse the repository at this point in the history
Fix commentsSection (fix #3)
  • Loading branch information
nicholaswilde committed Apr 24, 2022
2 parents ea8415e + ae6bf22 commit 7c1a9c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
7 changes: 4 additions & 3 deletions cmd/cook-docs/testdata/My Test Recipe.cook
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
>> servings: 6
>> source: https://www.somewebsite.com/pizza-balls
-- Header comment

Make 6 pizza balls using @tipo zero flour{820%g}, @water{533%ml}, @salt{24.6%g} and @fresh yeast{1.6%g}. Put in a #fridge for ~{2%days}.
Make 6 pizza balls using @tipo zero flour{820%g}, @water{533%ml}, @salt{24.6%g} and @fresh yeast{1.6%g}. Put in a #fridge for ~{2%days}. -- step 1 comment

Set #oven to max temperature and heat #pizza stone{} for about ~{40%minutes}.
Set #oven to max temperature and heat #pizza stone{} for about ~{40%minutes}. -- step 2 comment

Make some tomato sauce with @chopped tomato{3%cans} and @garlic{3%cloves} and @dried oregano{3%tbsp}. Put on a #pan and leave for ~{15%minutes} occasionally stirring.
Make some tomato sauce with @chopped tomato{3%cans} and @garlic{3%cloves} and @dried oregano{3%tbsp}. [- step 3 comment -] Put on a #pan and leave for ~{15%minutes} occasionally stirring.

Make pizzas putting some tomato sauce with #spoon on top of flattened dough. Add @fresh basil{18%leaves}, @parma ham{3%packs} and @mozzarella{3%packs}.

Expand Down
6 changes: 1 addition & 5 deletions pkg/document/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,14 @@ func getCommentsTemplate() string {
templateBuilder.WriteString("{{ end }}")

templateBuilder.WriteString(`{{ define "cook.comments" }}`)
//templateBuilder.WriteString("{{ range .Steps }}{{- range .Comments }}\n- {{.}}{{- end }}{{- end }}")
templateBuilder.WriteString("{{ range .Steps }}{{ range .Comments }}\n- {{.}}{{- end }}{{- end }}")
templateBuilder.WriteString("{{ end }}")

templateBuilder.WriteString(`{{ define "cook.commentsSection" }}`)
templateBuilder.WriteString("{{ range .Steps }}")
templateBuilder.WriteString("{{ if .Comments }}")
templateBuilder.WriteString(`{{ template "cook.commentsHeader" . }}`)
templateBuilder.WriteString("\n")
templateBuilder.WriteString(`{{ template "cook.comments" . }}`)
templateBuilder.WriteString("{{ end }}")
templateBuilder.WriteString("{{ end }}")
templateBuilder.WriteString("{{ end }}")

return templateBuilder.String()
}
Expand Down
10 changes: 0 additions & 10 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ github.com/Masterminds/semver/v3
# github.com/Masterminds/sprig/v3 v3.2.2
## explicit; go 1.13
github.com/Masterminds/sprig/v3
# github.com/alecthomas/gometalinter v3.0.0+incompatible
## explicit
# github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
## explicit; go 1.15
# github.com/aquilax/cooklang-go v0.1.6
## explicit; go 1.17
github.com/aquilax/cooklang-go
Expand All @@ -20,8 +16,6 @@ github.com/davecgh/go-spew/spew
# github.com/fsnotify/fsnotify v1.5.1
## explicit; go 1.13
github.com/fsnotify/fsnotify
# github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
## explicit; go 1.13
# github.com/google/uuid v1.1.2
## explicit
github.com/google/uuid
Expand Down Expand Up @@ -60,8 +54,6 @@ github.com/mitchellh/mapstructure
# github.com/mitchellh/reflectwalk v1.0.0
## explicit
github.com/mitchellh/reflectwalk
# github.com/nicksnyder/go-i18n v1.10.1
## explicit
# github.com/pelletier/go-toml v1.9.5
## explicit; go 1.12
github.com/pelletier/go-toml
Expand Down Expand Up @@ -126,8 +118,6 @@ golang.org/x/text/unicode/norm
## explicit; go 1.17
# golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f
## explicit; go 1.11
# gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20191105091915-95d230a53780
## explicit
# gopkg.in/ini.v1 v1.66.4
## explicit
gopkg.in/ini.v1
Expand Down

0 comments on commit 7c1a9c6

Please sign in to comment.