Merge pull request #718 from Shopify/docs-misc-fixes

Docs misc fixes
This commit is contained in:
Justin Li
2016-03-19 00:23:05 -04:00
9 changed files with 24 additions and 124 deletions

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
_site/
.sass-cache/
node_modules/
Gemfile.lock
# Compiled source #
###################
@@ -38,4 +39,4 @@ node_modules/
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Thumbs.db

View File

@@ -4,7 +4,7 @@ repository: https://github.com/Shopify/liquid
# Build settings
baseurl: /liquid # the subpath of your site, e.g. /blog/
url: http://liquidmarkup.org # the base hostname & protocol for your site
url: https://shopify.github.io # the base hostname & protocol for your site
markdown: redcarpet
redcarpet:
extensions: ["with_toc_data", "tables", "disable_indented_code_blocks", "no_intra_emphasis"]

View File

@@ -1,22 +1,22 @@
<div class="home-users-grid">
<div class="home-users-grid__item">
<a href="http://jekyllrb.com/" target="_blank">
<img src="{{ "/images/jekyll-logo.png" | prepend: site.baseurl }}" />
<a href="http://jekyllrb.com" target="_blank">
<img src="{{ '/images/jekyll-logo.png' | prepend: site.baseurl }}" alt="Jekyll logo" />
</a>
</div>
<div class="home-users-grid__item">
<a href="http://www.desk.com/" target="_blank">
<img src="{{ "/images/salesforcedesk-logo.png" | prepend: site.baseurl }}" />
<a href="http://www.desk.com" target="_blank">
<img src="{{ '/images/salesforcedesk-logo.png' | prepend: site.baseurl }}" alt="Desk logo" />
</a>
</div>
<div class="home-users-grid__item">
<a href="https://www.zendesk.com/ " target="_blank">
<img src="{{ "/images/zendesk-logo.png" | prepend: site.baseurl }}" />
<a href="//www.zendesk.com" target="_blank">
<img src="{{ '/images/zendesk-logo.png' | prepend: site.baseurl }}" alt="ZenDesk logo" />
</a>
</div>
<div class="home-users-grid__item">
<a href="http://500px.com/" target="_blank">
<img src="{{ "/images/500px-logo.png" | prepend: site.baseurl }}" />
<a href="//500px.com" target="_blank">
<img src="{{ '/images/500px-logo.png' | prepend: site.baseurl }}" alt="500px logo" />
</a>
</div>
</div>

View File

@@ -9,11 +9,11 @@
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
<link rel="stylesheet" href="{{ '/css/main.css' | prepend: site.baseurl }}">
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>

View File

@@ -1,48 +0,0 @@
---
title: Handles
---
A handle is used to access the attributes of a Liquid object. By default, the handle is the object's title in lowercase with any spaces and special characters replaced by hyphens (-).
For example, a page with the title "About Us" can be accessed in Liquid via its handle `about-us` as shown below:
{% highlight liquid %}
{% raw %}
<!-- the content of the About Us page -->
{{ pages.about-us.content }}
{% endraw %}
{% endhighlight %}
## Creating handles
An object with the title "Shirt" will automatically be given the handle `shirt`. If there is already an object with the handle `shirt`, the handle will auto-increment. In other words, "Shirt" objects created after the first one will receive the handle `shirt-1`, `shirt-2`, and so on.
Whitespace in titles is replaced by hyphens in handles. For example, the title "My Shiny New Title" will be given the handle `my-shiny-new-title`.
Handles also determine the URL of their corresponding objects. For example, a page with the handle `about-us` would have the url `/pages/about-us`.
Websites often rely on static handles for pages, posts, or objects. To preserve design elements and avoid broken links, if you modify the title of an object, **its handle is not automatically updated**. For example, if you were to change a page title from "About Us" to "About This Website", its handle would still be `about-us`.
You can change an object's handle manually (TK how to change a handle manually)
## Accessing handle attributes
In many cases you may know the handle of a object whose attributes you want to access. You can access its attributes by pluralizing the name of the object, then using either the square bracket ( [ ] ) or dot ( . ) notation.
<div class="code-block code-block--input">
{% highlight liquid %}
{% raw %}
{{ pages.about-us.title }}
{{ pages["about-us"].title }}
{% endraw %}
{% endhighlight %}
</div>
<div class="code-block code-block--output">
{% highlight text %}
About Us
About Us
{% endhighlight %}
</div>
In the example above, notice that we are using `pages` as opposed to `page`.

View File

@@ -42,9 +42,9 @@ Hello Adam!
Tags can be categorized into three types:
- [Control flow](/tags/control-flow)
- [Iteration](/tags/iteration)
- [Variable assignments](/tags/variable)
- [Control flow]({{ "/tags/control-flow" | prepend: site.baseurl }})
- [Iteration]({{ "/tags/iteration" | prepend: site.baseurl }})
- [Variable assignments]({{ "/tags/variable" | prepend: site.baseurl }})
You can read more about each type of tag in their respective sections.

View File

@@ -18,13 +18,13 @@ In the example below, the string "Tobi" is not a boolean, but it is truthy in a
{% raw %}
{% assign tobi = "Tobi" %}
{% if tobi == true %}
{% if tobi %}
This condition will always be true.
{% endif %}
{% endraw %}
```
[Strings](/basics/types/#string), even when empty, are truthy. The example below will result in empty HTML tags if `settings.fp_heading` is empty:
[Strings]({{ "/basics/types/#string" | prepend: site.baseurl }}), even when empty, are truthy. The example below will result in empty HTML tags if `settings.fp_heading` is empty:
```liquid
{% raw %}
@@ -38,23 +38,9 @@ In the example below, the string "Tobi" is not a boolean, but it is truthy in a
<h1></h1>
```
[EmptyDrops](/basics/types/#emptydrop) are also truthy. In the example below, if `settings.page` is an empty string or set to a hidden or deleted object, you will end up with an EmptyDrop. The result is an empty `div`:
```liquid
{% raw %}
{% if pages[settings.page] %}
<div>{{ pages[settings.page].content }}</div>
{% endif %}
{% endraw %}
```
```html
<div></div>
```
## Falsy
The falsy values in Liquid are [`nil`](/basics/types/#nil) and [`false`](/basics/types/#boolean).
The falsy values in Liquid are [`nil`]({{ "/basics/types/#nil" | prepend: site.baseurl }}) and [`false`]({{ "/basics/types/#boolean" | prepend: site.baseurl }}).
## Summary

View File

@@ -9,9 +9,8 @@ Liquid objects can have one of six types:
- [Boolean](#boolean)
- [Nil](#nil)
- [Array](#array)
- [EmptyDrop](#emptydrop)
You can initialize Liquid variables with the [assign](/tags/#assign) or [capture](/tags/#capture) tags.
You can initialize Liquid variables with the [assign]({{ "/tags/variable/#assign" | prepend: site.baseurl }}) or [capture]({{ "/tags/variable/#capture" | prepend: site.baseurl }}) tags.
## String
@@ -49,7 +48,7 @@ Booleans are either `true` or `false`. No quotations are necessary when declarin
Nil is a special empty value that is returned when Liquid code has no results. It is **not** a string with the characters "nil".
Nil is [treated as false](/basics/truthy-and-falsy) in the conditions of `if` blocks and other Liquid tags that check the truthfulness of a statement.
Nil is [treated as false]({{ "/basics/truthy-and-falsy" | prepend: site.baseurl }}) in the conditions of `if` blocks and other Liquid tags that check the truthfulness of a statement.
In the following example, if the user does not exist (that is, `user` returns `nil`), Liquid will not print the greeting:
@@ -79,7 +78,7 @@ Arrays hold lists of variables of any type.
### Accessing items in arrays
To access all the items in an array, you can loop through each item in the array using an [iteration tag](/tags/iteration/).
To access all the items in an array, you can loop through each item in the array using an [iteration tag]({{ "/tags/iteration" | prepend: site.baseurl }}).
```liquid
{% raw %}
@@ -119,42 +118,4 @@ Adam
You cannot initialize arrays using only Liquid.
You can, however, use the [split](/filters/split) filter to break a string into an array of substrings.
## EmptyDrop
An EmptyDrop object is returned if you try to access a deleted object by name. In the example below, `page_1`, `page_2` and `page_3` are all EmptyDrop objects.
```liquid
{% raw %}
{% assign variable = "hello" %}
{% assign page_1 = pages[variable] %}
{% assign page_2 = pages["does-not-exist"] %}
{% assign page_3 = pages.this-handle-does-not-exist %}
{% endraw %}
```
EmptyDrop objects only have one attribute, `empty?`, which is always *true*.
Collections and pages that *do* exist do not have an `empty?` attribute. Their `empty?` is "falsy", which means that calling it inside an if statement will return *false*. When using an `unless` statement on existing collections and pages, `empty?` will return `true`.
### Checking for emptiness
Using the `empty?` attribute, you can check to see if an object exists or not before you access any of its attributes.
```liquid
{% raw %}
{% unless pages.about.empty? %}
<!-- This will only print if the page with handle 'about' is not empty -->
<h1>{{ pages.frontpage.title }}</h1>
<div>{{ pages.frontpage.content }}</div>
{% endunless %}
{% endraw %}
```
If you don't check for emptiness first, Liquid might print empty HTML elements to the page:
```html
<h1></h1>
<div></div>
```
You can, however, use the [split]({{ "/filters/split" | prepend: site.baseurl }}) filter to break a string into an array of substrings.

View File

@@ -4,7 +4,7 @@ title: divided_by
Divides a number by the specified number.
The result is rounded down to the nearest integer (that is, the [floor](/filters/floor)).
The result is rounded down to the nearest integer (that is, the [floor]({{ "/filters/floor" | prepend: site.baseurl }})).
```liquid
{% raw %}