Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@f5devcentral/f5-fast-core
Advanced tools
This module provides a framework for handling templates.
To install this module run:
npm install @f5devcentral/f5-fast-core
A command line interface is provided via a fast
binary.
The help text is provided below and 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 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
Below is a basic example for loading a template without any additional type schema:
const fast = require('@f5devcentral/f5-fast-core');
const ymldata = `
view:
message: Hello!
definitions:
body:
template:
<body>
<h1>{{message}}</h1>
</body>
template: |
<html>
{{> body}}
</html>
`;
fast.Template.loadYaml(ymldata)
.then((template) => {
console.log(template.getParametersSchema());
console.log(template.render({message: "Hello world!"}));
});
In addition to Template.loadYaml()
, a Template
can be created from Mustache data using Template.loadMst()
:
const fast = require('@f5devcentral/f5-fast-core');
const mstdata = '{{message}}';
fast.Template.loadMst(ymldata)
.then((template) => {
console.log(template.getParametersSchema());
console.log(template.render({message: "Hello world!"}));
});
To support user-defined types, a SchemaProvider
must be used.
The FsSchemaProvider
can be used to load schema from disk:
const fast = require('@f5devcentral/f5-fast-core');
const templatesPath = '/path/to/templatesdir'; // directory containing types.json
const schemaProvider = new fast.FsSchemaProvider(templatesPath);
const mstdata = '{{virtual_port:types:port}}';
fast.Template.loadMst(mstdata, schemaProvider)
.then((template) => {
console.log(template.getParametersSchema());
console.log(template.render({virtual_port: 443});
});
A higher-level API is available for loading templates via TemplateProvider
classes.
These classes will handle calling the correct load function (Template.loadYaml()
vs Template.loadMst()
) and can also handle schemas.
For example, to load "templates sets" (a collection of template source files) from a given directory, the FsTemplateProvider
class can be used:
const fast = require('@f5devcentral/f5-fast-core');
const templatesPath = '/path/to/templatesdir';
const templateProvider = new fast.FsTemplateProvider(templatesPath);
templateProvider.fetch('templateSetName/templateName')
.then((template) => {
console.log(template.getParametersSchema());
console.log(template.render({
var: "value",
boolVar: false
}));
});
npm
commands should be run in the core subdirectory, not at the top-level.
npm run lint
npm test
Both of these are run as part of the CI pipeline for this repo.
For more information about FAST, see FAST Documentation
Copyright 2014-2020 F5 Networks Inc.
Before you start contributing to any project sponsored by F5 Networks, Inc. (F5) on GitHub, you will need to sign a Contributor License Agreement (CLA).
If you are signing as an individual, we recommend that you talk to your employer (if applicable) before signing the CLA since some employment agreements may have restrictions on your contributions to other projects. Otherwise by submitting a CLA you represent that you are legally entitled to grant the licenses recited therein.
If your employer has rights to intellectual property that you create, such as your contributions, you represent that you have received permission to make contributions on behalf of that employer, that your employer has waived such rights for your contributions, or that your employer has executed a separate CLA with F5.
If you are signing on behalf of a company, you represent that you are legally entitled to grant the license recited therein. You represent further that each employee of the entity that submits contributions is authorized to submit such contributions on behalf of the entity pursuant to the CLA.
v0.5.1
Initial, independent release (previously part of f5-appsvcs-templates)
FAQs
The core module for F5 Application Services Templates
The npm package @f5devcentral/f5-fast-core receives a total of 92 weekly downloads. As such, @f5devcentral/f5-fast-core popularity was classified as not popular.
We found that @f5devcentral/f5-fast-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.