Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macro install instructions to docs pages #5330

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion templates/docs/building-vanilla.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ context:
title: Building with Vanilla
---

Here you will find information on how you can use different tools to build Vanilla into production CSS.
Here you will find information on how you can use different tools to build
Vanilla into production HTML and CSS.

## Sass

Expand Down Expand Up @@ -61,6 +62,39 @@ To watch for changes in your Sass files, add the following script to your `packa

Now if you open an extra terminal and run `yarn watch-css`, the CSS will be rebuilt every time your Sass files are edited and saved.

## Jinja Macros

A variety of Vanilla's components and patterns are offered as
[Jinja Macros](https://jinja.palletsprojects.com/templates/#macros), which may
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
be useful to you if you build sites using the
[Jinja](https://jinja.palletsprojects.com/) templating engine. These Macros can
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
help abstract away some of the complexity of Vanilla's HTML, making producing
complex page layouts simpler and faster.

In order to pull Vanilla's Macros into your project, you may need to expose them
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
to your webserver or templating engine. An example of this using Flask and Jinja
might look like the following:

```
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
from flask import Flask
from jinja2 import ChoiceLoader, FileSystemLoader

app = Flask(__name__)

# ChoiceLoader attempts loading templates from each path in successive order
loader = ChoiceLoader([
FileSystemLoader('templates'),
FileSystemLoader('node_modules/vanilla-framework/templates/')
])

# Loader supplied to jinja_loader overwrites default jinja_loader
app.jinja_loader = loader

```

After making the Macros available to your webserver/templating engine, see the
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
individual component/pattern docs for import and usage instructions.

## Webpack

[Webpack](https://webpack.js.org/) is used to compile JavaScript modules, and can be used to inject Vanilla styles to the DOM. To get set up using Vanilla with Webpack, add the `webpack` and `vanilla-framework` packages to your project dependencies:
Expand Down
12 changes: 12 additions & 0 deletions templates/docs/patterns/hero/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,15 @@ View example of the hero pattern in fallback configuration

Since Patterns leverage many other parts of Vanilla in their composition and content, we
recommend [importing the entirety of Vanilla](/docs#install) for full support.

### Macro

If you'd like to use the Jinja Macro, first follow the
[Jinja Macros build instructions](/docs/building-vanilla#jinja-macros). The
hero pattern can then be imported as such:

```
{% raw -%}
{% from "_macros/vf_hero.jinja" import vf_hero %}
{%- endraw %}
```
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 12 additions & 0 deletions templates/docs/patterns/tiered-list/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,15 @@ View example of the tiered list pattern
Since Patterns leverage many other parts of Vanilla in their composition and
content, we recommend [importing the entirety of Vanilla](/docs#install) for
full support.

### Macro

If you'd like to use the Jinja Macro, first follow the
[Jinja Macros build instructions](/docs/building-vanilla#jinja-macros). The
tiered list pattern can then be imported as such:

```
{% raw -%}
{% from "_macros/vf_tiered-list.jinja" import vf_tiered_list %}
{%- endraw %}
```
pastelcyborg marked this conversation as resolved.
Show resolved Hide resolved
Loading