gitbook-plugin-variables
Load variables from files and use them in your GitBook templates
Last updated 2 years ago by alphahydrae .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gitbook-plugin-variables 
SYNC missed versions from official npm registry.

GitBook Variables Plugin

Load variables from files and use them in your GitBook templates.

npm version build status license

Requirements

Usage

Add the plugin to your book.json file:

{
  "plugins": [ "variables" ],
  "pluginsConfig": {
    "variables": {
      "files": {
        "myVariable": "data.json"
      }
    }
  }
}

This will load the data.json file in your book's directory and make its contents available as the myVariable variable. You may then use it in your Markdown, for example like this:

The file `data.json` contains: {{ book.myVariable }}

Configuration

The following options are available under your book.json file's pluginsConfig.variables section.

files

An object where each key is a variable to add to your book, and the corresponding value is a file path or an array of file paths to load into that variable.

This configuration loads the contents of 2 files into variables a and b:

{
  "plugins": [ "variables" ],
  "pluginsConfig": {
    "variables": {
      "files": {
        "a": "data/a/some.json",
        "b": "data/b/c/some.yml"
      }
    }
  }
}

Multiple files may be loaded into the same variable:

{
  "plugins": [ "variables" ],
  "pluginsConfig": {
    "variables": {
      "files": {
        "a": [ "data/a/some.json", "data/b/c/some.yml" ]
      }
    }
  }
}
  • Successive files representing arrays are concatenated in order (e.g. ["foo"] and ["bar"] becomes ["foo","bar"]).
  • Successive files representing objects are merged in order. (e.g. {"foo":"bar"} and {"foo":"qux","bar":"baz"} becomes {"foo":"qux","bar":"baz"}).
  • Other or differing successive types simply replace the previous value (e.g. ["foo"] and {"foo":"bar"} becomes {"foo":"bar"}).

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

3 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 3
Dependencies (5)
Dev Dependencies (24)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |