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
.
include
You'll need to pass a context object from your code or Yaml file (example), 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": "element",
"link_href": "JavaScript:Void(0);",
"buttonType": "default",
"text": "A default link"
}
%}
{% include "../path_to/vf-link/vf-link.njk" %}
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.
{% render '@vf-link', {
"component-type": "element",
"link_href": "JavaScript:Void(0);",
"buttonType": "default",
"text": "A default link"
} %}
<ahref="JavaScript:Void(0);"class="vf-link">A default link</a>
This is an example of using inline links when you are using the .vf-content
container.
This component is distributed with npm. After installing npm, you can install the vf-link
with this command.
$ yarn add --dev @visual-framework/vf-link
The source files included are written in Sass(scss
). You can point your Sass include-path
at your node_modules
directory and import it like this.
@import "@visual-framework/vf-link/index.scss";
Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter
vf-navigation--on-this-page
.vf-intro
so it's a white background, removes the padding.vf-intro
to be the 'correct' buttons.vf-component-assets:everything
on local dev/css/app.css
vf-css:generate-component-css
File system location: components/vf-link
Find an issue on this page? Propose a change or discuss it.