TAML is a tiny subset of YAML. See https://yihui.org/litedown/#sec:yaml-syntax for its specifications.
taml_load(x, envir = parent.frame())
taml_file(path)
taml_save(x, path = NULL, indent = " ")
For taml_load()
, a character vector of the YAML content. For
taml_save()
, a list to be converted to YAML.
The environment in which R expressions in YAML are evaluated. To
disable the evaluation, use envir = FALSE
.
A file path to read from or write to.
A character string to indent sub-lists by one level.
taml_load()
and taml_file()
return a list; if path = NULL
,
taml_save()
returns a character vector, otherwise the vector is written
to the file specified by the path
.
(res = taml_load("a: 1"))
#> $a
#> [1] 1
#>
taml_save(res)
#> a: 1
(res = taml_load("a: 1\nb: \"foo\"\nc: null"))
#> $a
#> [1] 1
#>
#> $b
#> [1] "foo"
#>
#> $c
#> NULL
#>
taml_save(res)
#> a: 1
#> b: "foo"
#> c: null
(res = taml_load("a:\n b: false\n c: true\n d: 1.234\ne: bar"))
#> $a
#> $a$b
#> [1] FALSE
#>
#> $a$c
#> [1] TRUE
#>
#> $a$d
#> [1] 1.234
#>
#>
#> $e
#> [1] "bar"
#>
taml_save(res)
#> a:
#> b: false
#> c: true
#> d: 1.234
#> e: "bar"
taml_save(res, indent = "\t")
#> a:
#> b: false
#> c: true
#> d: 1.234
#> e: "bar"
taml_load("a: !expr paste(1:10, collapse = \", \")")
#> $a
#> [1] "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
#>
taml_load("a: [1, 3, 4, 2]")
#> $a
#> [1] 1 3 4 2
#>
taml_load("a: [1, \"abc\", 4, 2]")
#> $a
#> [1] "1" "abc" "4" "2"
#>
taml_load("a: [\"foo\", \"bar\"]")
#> $a
#> [1] "foo" "bar"
#>
taml_load("a: [true, false, true]")
#> $a
#> [1] TRUE FALSE TRUE
#>
# the other form of array is not supported
taml_load("a:\n - b\n - c")
#> $a
#> list()
#>
# and you must use the yaml package
if (loadable("yaml")) yaml_load("a:\n - b\n - c")
#> $a
#> [1] "b" "c"
#>