Built in Helpers

Page Variables

Acetate provides the following variables you can use any of these variables in your templates.

Variable Description Example
stats File statistics for this pages template. Node fs.Stats Will be false if this page was not generated from a template.
src Path to this file from the source folder 'blog/posts/hello-world.md'
dest Output path for this file relative to the output folder 'blog/posts/hello-world/index.html'
url URL for this page. 'blog/posts/hello-world/'
templatepath Full path to this template from root. This will differ between platforms. '/Users/joe/blog/posts/hello-world/index.html'
relativePath Relative path back to root from this page. ../../


<!-- last modified: {{ stats.mtime }} -->
<!-- template: {{ src }} -->
<a href="{{ relativePath }}">Home</a>

Link Helper

Acetate's {% link %} helper has a number of useful features to speed up development.

<!-- basic link -->
{% link '/', 'Home' %}

<!-- you can pass any additional HTML attributes you need -->
{% link '/', 'Home', 'data-foo'='Foo', target='_blank' %}
{% link '/', 'Home', id="logo", class="nav-link" %}

<!-- relative links will be resolved against the current pages URL -->
{% link '../', 'Back' %}
{% link '../', 'Back', class="back-link" %}

<!-- Use `activeClass` to customize the class that gets added if this link is active -->
{% link '../', 'Back', activeClass="active" %}

<!-- Use `requireExactMatch` if the active class should be applied only if this page url matches the URL exactly -->
{% link '/', 'Home', requireExactMatch=true %}

<!-- You can use link for external links too -->
{% link 'http://example.com', 'Example', class="external-link" %}
{% link '//example.com', 'Example' %}

Highlight Helper

Acetate provides a highlight helper that will use highlight.js to syntax highlight blocks of code.

{% highlight 'js'%}
let message = "Acetate is awesome!";
{% endhighlight %}

You can also omit the language hint to auto detect the language or pass text or plain to disable highlighting.

{% highlight %}
var message = "Acetate is awesome!";
{% endhighlight %}

You can use one of highlight.js's stylesheets to style the resulting code block.

Markdown Helper

You can also render Markdown inside a page template with the markdown block.

{% markdown %}
# Acetate is awesome

Markdown is awesome too.
{% endmarkdown %}

Edit this Page on GitHub