Yass

Helpers

Your .liquid files have access to all the standard Liquid tags and filters plus the following ones from Yass.

Variables

page

An object representing the current page. Properties:

<h1>{{ page.title }}</h1>

site.files

Any array of all (published) files that will be written dist/. Same properties as page.

{% assign css_files = site.files | where: "extname", ".css" %}
{% for file in css_files %}
    <link rel="stylesheet" href="{{ file.path | relative }}">
{% endfor %}

Filters

relative

Modifies a path to be relative to the current file. Useful in layouts and template that need to refer to other files.

<script src="{{ "assets/main.js" | relative }}"></script>

If the above HTML was in a/b/c.html.liquid, the script source would be ../../assets/main.js.

strip_index

Removes trailing index.htmls from URLs, on the assumption that web servers will handle that. Can be disabled with the --no-strip-index option (useful for development builds).

<a href="{{ "posts/index.html" | relative | strip_index }}">Posts</a>

match

Returns true if the string matches the regex.

{% assign is_asset = page.path | match: "\.(css|js|jpe?g)$" %}

where_match

Works like Liquid’s built-it where, but accepts a regular expression.

{% assign posts = where_match: "path", "^posts/.+\.html$" %}

where_not

Works like Liquid’s built-it where, but returns object that don’t match.

{% assign posts = where_not: "hidden", true %}

Tags

highlight

Converts the given code into something useable by Highlight.js.

{% highlight ruby %}
puts "Yass!"
{% endhighlight %}

Hightlight.js CSS and JS files with common languages are included by default with yass init. Download your own versions if you want different languages or themes.

render_content

Renders a template, passing the block as a variable named content.

The following will render the template templates/my_template.liquid:

{% render_content "my_template" %}
<p>This will be rendered inside of "my_template" from a variable called "content"</p>
{% endrender_content %}