Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
Using include
You'll need to pass a context object from your code or Yaml file (exampe), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "form",
"fieldset_legend": {
"legend__text": "A Fieldset Legend"
}
}
%}
{% include "../path_to/vf-form__fieldset/vf-form__fieldset.njk" %}
Using render
This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
Using include
You'll need to pass a context object from your code or Yaml file (exampe), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "form",
"fieldset__error": {
"error": true,
"helper_text": "Something has gone terribly wrong."
},
"fieldset_legend": {
"legend__text": "Another Fieldset Legend"
}
}
%}
{% include "../path_to/vf-form__fieldset/vf-form__fieldset.njk" %}
Using render
This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
Use the vf-form__fieldset component to display a relationship between multiple form inputs. You can also need use a vf-form__fieldset inside of another vf-form__fieldset, this would be good to group multiple vf-form__checkbox inputs and allow for a vf-form__legend to give the inputs a heading or question. To make it more obvious what we are asking the site visitor to fill out and why, it is recommened to use a vf-form__legend within each vf_form__fieldset.
Installation info
This repository is distributed with [npm][https://www.npmjs.com/]. After [installing npm][https://www.npmjs.com/get-npm] and yarn, you can install vf-form__fieldset with this command.