Skip to content

Latest commit

 

History

History
117 lines (94 loc) · 2.83 KB

getting_started.md

File metadata and controls

117 lines (94 loc) · 2.83 KB

Getting Started

Installation

To install this module run:

npm install @f5devcentral/f5-fast-core

CLI

A command line interface is provided via a fast binary.

FAST can render a basic template with the CLI. Here is an example using a template file named hello.yaml:

  parameters:
    message: Hello!
  definitions:
    body:
      template:
        <body>
          <h1>{{message}}</h1>
        </body>
  template: |
    <html>
      {{> body}}
    </html>

With this command to render the template:

fast render hello.yaml

For help, like the text provided below, is also accessed via fast --help:

fast <command>

Commands:
  fast validate <file>                                validate given template source file
  fast schema <file>                                  get template parameter schema for given template source file
  fast guiSchema <file>                               get template parameter schema (modified for use with JSON Editor) for given template source file
  fast validateParameters <tmplFile> <parameterFile>  validate supplied template parameters with given template
  fast render <tmplFile> [parameterFile]              render given template file with supplied parameters
  fast validateTemplateSet <templateSetPath>          validate supplied template set
  fast htmlpreview <tmplFile> [parameterFile]         generate a static HTML file with a preview editor to standard out
  fast packageTemplateSet <templateSetPath> [dst]     build a package for a given template set

Options:
  --help     Show help                                                                                         [boolean]
  --version  Show version number                                                                               [boolean]

For more information on a given command use the --help flag combined with a command:

fast <command> --help

The CLI can also be accessed by executing cli.js. For example:

./cli.js render path/to/template

ContentTypes

When FAST renders it is doing string replacement via Mustache, which is agnostic to the output type. However, specifying a contentType in the template can enable some additional features:

  • Post-processing steps (e.g., strip dangling commas for JSON)
  • Smarter merges
  • Smarter handling of some data types

Here is an example of using application/json for the content type:

Template:

title: Members in JSON List
contentType: application/json
template: |
  {
    "members": [
      {{#members}} 
        { "ipAddr": "{{ . }}" },
      {{/members}}
    ]
  }

Parameters:

  members: 
    - 10.0.0.1
    - 10.0.0.2
    - 10.0.0.3

Output:

  {
    "members": [
      {
        "ipAddr": "10.0.0.1"
      },
      {
        "ipAddr": "10.0.0.2"
      },
      {
        "ipAddr": "10.0.0.3"
      }
    ]
  }