The Ghost Themes Developer Hub

Welcome to the Ghost Themes developer hub. You'll find comprehensive guides and documentation to help you start working with Ghost Themes as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

encode

{{encode}} Helper - Encode a value using for using as part of a URL encodeURIComponent

Usage: {{encode value}}

Type
Parameters
Attributes
  • value (string)

n/a

Description

{{encode}} is a simple output helper which will encode a given string so that it can be used in a URL.

The most obvious example of where this is useful is shown in Casper's post.hbs, for outputting a twitter share link:

<a class="icon-twitter" href="http://twitter.com/share?text={{encode title}}&url={{url absolute="true"}}"
    onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
    <span class="hidden">Twitter</span>
</a>

Without using the {{encode}} helper on the post's title, the spaces and other punctuation in the title would not be handled correctly.

encode

{{encode}} Helper - Encode a value using for using as part of a URL encodeURIComponent