diff --git a/index.md b/index.md index 1ef72a3..1cf1975 100644 --- a/index.md +++ b/index.md @@ -1,5 +1,6 @@ --- layout: default +description: Documentation for the Liquid template language, created by Shopify. --- {% include home-banner.html %} diff --git a/tags/_theme.md b/tags/_theme.md deleted file mode 100644 index 812ace5..0000000 --- a/tags/_theme.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -title: Theme ---- - - -Theme Tags have various functions, including: - -- Outputting template-specific HTML markup -- Telling the theme which layout and snippets to use -- Splitting a returned array into multiple pages. - - -### comment - -

Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed.

- -
-{% highlight html %}{% raw %} - My name is {% comment %}super{% endcomment %} Shopify. -{% endraw %}{% endhighlight %} -
- -
-{% highlight html %}{% raw %} -My name is Shopify. -{% endraw %}{% endhighlight %} -
- -### include - -Inserts a snippet from the **snippets** folder of a theme. - -{% highlight html %}{% raw %} -{% include 'snippet-name' %} -{% endraw %}{% endhighlight %} - -Note that the .liquid extension is omitted in the above code. - -When a snippet is included, the code inside it will have access to the variables within its parent template. - -

Including multiple variables in a snippet

- -There are two ways to include multiple variables in a snippet. You can assign and include them on different lines: - -{% highlight html %}{% raw %} -{% assign snippet_variable = 'this is it' %} -{% assign snippet_variable_two = 'this is also it' %} -{% include 'snippet' %} -{% endraw %}{% endhighlight %} - -Or you can consolidate them into one line of code: - -{% highlight html %}{% raw %} -{% include 'snippet', snippet_variable: 'this is it', snippet_variable_two: 'this is also it' %} -{% endraw %}{% endhighlight %} - -

parameters include

- -### with - -The with parameter assigns a value to a variable inside a snippet that shares the same name as the snippet. - -For example, we can have a snippet named **color.liquid** which contains the following: - -{% highlight html %}{% raw %} -color: '{{ color }}' -shape: '{{ shape }}' -{% endraw %}{% endhighlight %} - -Within **theme.liquid**, we can include the **color.liquid** snippet as follows: - -{% highlight html %}{% raw %} -{% assign shape = 'circle' %} -{% include 'color' %} -{% include 'color' with 'red' %} -{% include 'color' with 'blue' %} -{% assign shape = 'square' %} -{% include 'color' with 'red' %} -{% endraw %}{% endhighlight %} - -The output will be: - -{% highlight html %}{% raw %} -color: shape: 'circle' -color: 'red' shape: 'circle' -color: 'blue' shape: 'circle' -color: 'red' shape: 'square' -{% endraw %}{% endhighlight %} - -### form - -Creates an HTML <form> element with all the necessary attributes (action, id, etc.) and <input> to submit the form successfully. - -

parameters form

- -### new_comment - -Generates a form for creating a new comment in the article.liquid template. Requires the article object as a parameter. - -

Input

-
-{% highlight html %}{% raw %} -{% form "new_comment", article %} -... -{% endform %} -{% endraw %}{% endhighlight %} -
- - -

Output

-
-{% highlight html %}{% raw %} -
- - - ... -
-{% endraw %}{% endhighlight %} -
- -### layout - -Loads an alternate template file from the **layout** folder of a theme. If no alternate layout is defined, the **theme.liquid** template is loaded by default. - -{% highlight html %}{% raw %} - -{% layout 'alternate' %} -{% endraw %}{% endhighlight %} - -If you don't want **any** layout to be used on a specific template, you can use none. - -{% highlight html %}{% raw %} -{% layout none %} -{% endraw %}{% endhighlight %} - - - - - - - - - - - - - - - - -### paginate - -Splitting products, blog articles, and search results across multiple pages is a necessary component of theme design as you are limited to 50 results per page in any for loop. - -The paginate tag works in conjunction with the for tag to split content into numerous pages. It must wrap a for tag block that loops through an array, as shown in the example below: - -{% highlight html %}{% raw %} -{% paginate collection.products by 5 %} - {% for product in collection.products %} - - {% endfor %} -{% endpaginate %} -{% endraw %}{% endhighlight %} - -The by parameter is followed by an integer between 1 and 50 that tells the paginate tag how many results it should output per page. - - -Within paginate tags, you can access attributes of the paginate object. This includes the attributes to output the links required to navigate within the generated pages. - - -{% comment %} - -Accessing any attributes of the array you are paginating before the opening paginate tag will cause errors. To avoid this, make sure any variables - - -**Bad Example** -
-{% highlight html %}{% raw %} -{{ collection.title }} -{% paginate collection.products by 5 %} - {% for product in collection.products %} - {{ product.title }} - {% endfor %} -{% endpaginate %} -{% endraw %}{% endhighlight %} -
- - -**Good Example** -
-{% highlight html %}{% raw %} -{% paginate collection.products by 5 %} - {% for product in collection.products %} - - {% endfor %} -{% endpaginate %} -{% endraw %}{% endhighlight %} -
- -{% endcomment %} - - - - - - - - - - - - - - - - - - - - -### raw - -

Allows output of Liquid code on a page without being parsed.

- -

Input

- -
-
{% raw %}{{ 5 | plus: 6 }}{% endraw %} is equal to 11.
-
- -

Output

- -
-
{{ 5 | plus: 6 }} is equal to 11.
-
- - -