dati

A Go library/binary to parse & execute data against template langauges.
git clone git://src.gearsix.net/dati
Log | Files | Refs | Atom | README | LICENSE

README.md (3307B)


      1  
      2 DATI
      3 ----
      4 
      5 ```
      6 dati [OPTIONS]
      7 ```
      8 
      9 DATA
     10 ----
     11 
     12 Data is a file written in any data language (e.g. JSON or YAML), a list of
     13 supported languages can be seen in the README for the dati library.
     14 These files provide *key=value* data.
     15 
     16 dati generates a single data structure of all data contained within parsed
     17 data files.
     18 This super-structure is passed to each "root" template, where *value* data
     19 is accessed using the *key* strings.
     20 
     21 The data structure generated by dati will only have 1 absolute key: `"data"`
     22 (can be renamed using the **-dk**/**-data-key** option).
     23 This key will overwrite any other root key of the same name.
     24 Its value will be an array, where each element is the *key=value* data
     25 parsed one of the "data" files.
     26 
     27 Parsed "global data" will be written to the root of the data structure
     28 and into the root for each element of the "data" array.
     29 If a key within one of these objects conflicts with one of the keys in the
     30 "global data", then the "global data" key is ignored.
     31 
     32 
     33 TEMPLATES
     34 ---------
     35 
     36 All "root" template files passed to dati that have a file extension matching
     37 one of the supported templating languages will be parsed and executed
     38 against the generated data structure.
     39 
     40 All "parital" templates will be parsed into any "root" templates that have a
     41 file extension that match the same templating language.
     42 
     43 
     44 OPTIONS
     45 -------
     46 
     47 - **-r**, **-root** *PATH*<br>
     48 Path of the root template file to execute against.
     49 
     50 - **-p**, **-partial** *PATH ...*<br>
     51 Path of (multiple) template files that are called upon by at least
     52 one root template
     53 - If a directory is passed then all files within that directory
     54 will (recursively) be loaded.
     55 
     56 - **-gd**, **-global-data** *PATH ...*<br>
     57 Path of (multiple) data files to load as "global data".
     58 If a directory is passed then all files within that directory will
     59 (recursively) be loaded.
     60 
     61 - **-d**, **-data** *PATH ...*<br>
     62 path of (multiple) data files to load as "data". If a directory is passed
     63 then all files within that directory will (recursively) be loaded.
     64 
     65 
     66 - **-dk**, **-data-key** *NAME*<br>
     67 Set the name of the key used for the generated array of data. The
     68 default *data key* is "data".
     69 
     70 - **-sd**, **-sort-data** *ATTRIBUTE*<br>
     71 The file attribute to order data files by. If no value is provided,
     72 the data will be provided in the order it's loaded.
     73 - *Accepted values*: "filename", "modified".
     74 - A suffix can be appended to each value to set the sort order:
     75 "-asc" (for ascending), "-desc" (for descending).
     76 If not specified, this defaults to "-asc".
     77 
     78 - **-cfg** **-config** *FILE*<br>
     79 A data file to provide default values for the above options (CONFIG).
     80 
     81 
     82 CONFIG
     83 ------
     84 
     85 You might want to use the same options if you run dati multiple times
     86 for the same project. This can be done by creating a data file and
     87 passing the filepath to the *-cfg* argument.
     88 
     89 The key names for the options set in the config file must match the name of
     90 the argument option to set (long or short). For example (a config file in
     91 toml):
     92 
     93 ```
     94 root="~/templates/blog.mst"
     95 partial="~/templates/blog/"
     96 gd="./blog.json"
     97 data="./posts/"
     98 dk="posts"
     99 ```
    100 
    101 EXAMPLES
    102 --------
    103 
    104 ```
    105 dati -cfg ./dati.cfg -r templates/textfile.mst
    106 
    107 dati -r homepage.hmpl -p head.hmpl -p body.hmpl -gd meta.json -d posts/*
    108 ```
    109 
    110 see the examples/ directory in the dati repository for a cool example.
    111