From af47b3c1a770c47b5afc3389662a90632db05cee Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 17 Mar 2016 15:50:50 -0700 Subject: [PATCH] Fix documentation for push/pop/shift/unshift /cc https://github.com/jekyll/jekyll/pull/4384 --- site/_docs/templates.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/site/_docs/templates.md b/site/_docs/templates.md index ecb1c110..60892505 100644 --- a/site/_docs/templates.md +++ b/site/_docs/templates.md @@ -275,20 +275,33 @@ common tasks easier.

Array Filters

Push, pop, shift, and unshift elements from an Array.

+

These are NON-DESTRUCTIVE, i.e. they do not mutate the array, but rather make a copy and mutate that.

{% raw %}{{ page.tags | push: 'Spokane' }}{% endraw %} - {% raw %}{{ page.tags | pop }}{% endraw %} - {% raw %}{{ page.tags | shift }}{% endraw %} - {% raw %}{{ page.tags | unshift }}{% endraw %}

['Seattle', 'Tacoma', 'Spokane'] - ['Seattle', 'Tacoma'] +

+

+ {% raw %}{{ page.tags | pop }}{% endraw %} +

+

['Seattle'] +

+

+ {% raw %}{{ page.tags | shift }}{% endraw %} +

+

['Tacoma']

+

+ {% raw %}{{ page.tags | unshift: "Olympia" }}{% endraw %} +

+

+ ['Olympia', 'Seattle', 'Tacoma'] +