| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/yaml.R |
| 3 |
\name{taml_load} |
| 4 |
\alias{taml_load} |
| 5 |
\alias{taml_file} |
| 6 |
\alias{taml_save} |
| 7 |
\title{A simple YAML reader and writer} |
| 8 |
\usage{ |
| 9 |
taml_load(x, envir = parent.frame()) |
| 10 |
|
| 11 |
taml_file(path) |
| 12 |
|
| 13 |
taml_save(x, path = NULL, indent = " ") |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{x}{For \code{taml_load()}, a character vector of the YAML content. For |
| 17 |
\code{taml_save()}, a list to be converted to YAML.} |
| 18 |
|
| 19 |
\item{envir}{The environment in which R expressions in YAML are evaluated. To |
| 20 |
disable the evaluation, use \code{envir = FALSE}.} |
| 21 |
|
| 22 |
\item{path}{A file path to read from or write to.} |
| 23 |
|
| 24 |
\item{indent}{A character string to indent sub-lists by one level.} |
| 25 |
} |
| 26 |
\value{ |
| 27 |
\code{taml_load()} and \code{taml_file()} return a list; if \code{path = NULL}, |
| 28 |
\code{taml_save()} returns a character vector, otherwise the vector is written |
| 29 |
to the file specified by the \code{path}. |
| 30 |
} |
| 31 |
\description{ |
| 32 |
TAML is a tiny subset of YAML. See |
| 33 |
\url{https://pkg.yihui.org/litedown/book/#sec:yaml-syntax} for its |
| 34 |
specifications. |
| 35 |
} |
| 36 |
\examples{ |
| 37 |
(res = taml_load("a: 1")) |
| 38 |
taml_save(res) |
| 39 |
|
| 40 |
(res = taml_load("a: 1\nb: \"foo\"\nc: null")) |
| 41 |
taml_save(res) |
| 42 |
|
| 43 |
(res = taml_load("a:\n b: false\n c: true\n d: 1.234\ne: bar")) |
| 44 |
taml_save(res) |
| 45 |
taml_save(res, indent = "\t") |
| 46 |
|
| 47 |
taml_load("a: !expr paste(1:10, collapse = \", \")") |
| 48 |
taml_load("a: [1, 3, 4, 2]") |
| 49 |
taml_load("a: [1, \"abc\", 4, 2]") |
| 50 |
taml_load("a: [\"foo\", \"bar\"]") |
| 51 |
taml_load("a: [true, false, true]") |
| 52 |
# the other form of array is not supported |
| 53 |
taml_load("a:\n - b\n - c") |
| 54 |
# and you must use the yaml package |
| 55 |
if (loadable("yaml")) yaml_load("a:\n - b\n - c") |
| 56 |
} |