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" : "embl-element",
"logo_text" : "European Molecular Biology Laboratory Home",
"logo_href" : "/",
}
%}
{% include "../path_to/embl-logo/embl-logo.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 '@embl-logo', {
"component-type" : "embl-element",
"logo_text" : "European Molecular Biology Laboratory Home",
"logo_href" : "/",}
%}
<a href="/" class="embl-logo">
<span class="vf-u-sr-only" for="text">European Molecular Biology Laboratory Home</span>
</a>
This component is distributed with npm. After installing npm, you can install the embl-logo
with this command.
$ yarn add --dev @visual-framework/embl-logo
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/embl-logo/index.scss";
Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter
--extreme
variant.--extreme
.--extreme
version from 96px to 48px
File system location: components/embl-logo
Find an issue on this page? Propose a change or discuss it.