Skip to content

Commit

Permalink
fix fromYaml
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Apr 23, 2024
1 parent 17bb13f commit f40f40e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/nyml.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ proc `$`*(n: YAML): string =
proc toYAML*(json: JsonNode): string = dump(json)
proc toYAML*(json: string): string = dump(parseJson(json))

template fromYaml*(str: string, obj: typedesc[object]): untyped =
template fromYaml*[T: typedesc](str: string, obj: T): untyped =
## Add support for loose, direct to object parser using
## https://github.com/treeform/jsony
var yml = YAML.init(str, false, nil)
Expand All @@ -69,5 +69,5 @@ template fromYaml*(str: string, obj: typedesc[object]): untyped =
jsony.fromJson(jsonContent, obj)

# when isMainModule:
# echo yaml(readFile("test.yml"), data = %*{"hello": "yepsi"})
# echo yaml(readFile("typesense.yaml")).toJsonStr
# echo yaml(readFile("test.yml"), data = %*{"hello": "yepsi"}).toJsonStr()

0 comments on commit f40f40e

Please sign in to comment.