mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-13 07:50:43 -07:00
Compare commits
278
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e5911d3ee | ||
|
|
622b3b9a1d | ||
|
|
c52e75a9b5 | ||
|
|
99a59e39d8 | ||
|
|
2f8dc74f95 | ||
|
|
57d41e535f | ||
|
|
b2ddd33679 | ||
|
|
c26e5c61ea | ||
|
|
3fa5dc403a | ||
|
|
e19019517a | ||
|
|
b98d3d6097 | ||
|
|
77c2dfa989 | ||
|
|
d8f5d65e32 | ||
|
|
c2fab68b85 | ||
|
|
c99ddcbfc8 | ||
|
|
fb8432ca16 | ||
|
|
1b53edf052 | ||
|
|
b318616a97 | ||
|
|
fc5d02fe1c | ||
|
|
0f83e333c4 | ||
|
|
09e4fef712 | ||
|
|
9e0dc135ca | ||
|
|
d4222ff2b6 | ||
|
|
c4dce51f62 | ||
|
|
9542f1d961 | ||
|
|
32a327ed30 | ||
|
|
e47ea38940 | ||
|
|
537f53ef7c | ||
|
|
bcf72e42d2 | ||
|
|
7cfa4aa8bc | ||
|
|
cd467810fb | ||
|
|
109a1fe88a | ||
|
|
67f086040a | ||
|
|
aa6240f43c | ||
|
|
40bf603bfb | ||
|
|
ca2050446c | ||
|
|
506df22f41 | ||
|
|
c63fcdfe0a | ||
|
|
95dca87f49 | ||
|
|
6a01c98702 | ||
|
|
515ea65511 | ||
|
|
a136b74803 | ||
|
|
adf59df3d9 | ||
|
|
40ab3ef17c | ||
|
|
bea649dc63 | ||
|
|
ea6b176363 | ||
|
|
9ff1b88985 | ||
|
|
4cfd19a27e | ||
|
|
29d3ac003a | ||
|
|
3b7538566c | ||
|
|
01d1f08c6a | ||
|
|
1577b29127 | ||
|
|
58e6e416eb | ||
|
|
83ce52a5f1 | ||
|
|
ecfcbc3ed5 | ||
|
|
ca3a1bf995 | ||
|
|
061dabed98 | ||
|
|
d4159b6069 | ||
|
|
ecd707cb44 | ||
|
|
7a0afa372e | ||
|
|
1547da87a5 | ||
|
|
e0f4e8f232 | ||
|
|
f15825ac76 | ||
|
|
a79240a909 | ||
|
|
fbad7cf377 | ||
|
|
ea0bf2d30b | ||
|
|
d18fc08323 | ||
|
|
22cb0018a5 | ||
|
|
8845d1ada1 | ||
|
|
45e7d6b652 | ||
|
|
15c6d74646 | ||
|
|
d9a4a3d9d7 | ||
|
|
e9e3e306ee | ||
|
|
cea42bd165 | ||
|
|
725335bbc1 | ||
|
|
307c8befc5 | ||
|
|
aed39a43f5 | ||
|
|
a842b59246 | ||
|
|
b669229f69 | ||
|
|
b211fb67fb | ||
|
|
38a59f4c1d | ||
|
|
02364d1025 | ||
|
|
bed2727d60 | ||
|
|
ffb9206ef0 | ||
|
|
9ac8895a1b | ||
|
|
8959afe1a8 | ||
|
|
c17cf534db | ||
|
|
9f74627676 | ||
|
|
3b3be384df | ||
|
|
daeb5b1e67 | ||
|
|
8a6f25f3da | ||
|
|
c2878c24c6 | ||
|
|
16c38e37eb | ||
|
|
0589cf4aac | ||
|
|
aba49324c1 | ||
|
|
c4ae2e9012 | ||
|
|
7cdc482bc4 | ||
|
|
fbe0b39d85 | ||
|
|
ebf7f9232f | ||
|
|
a0b0c608c1 | ||
|
|
1db4219d2f | ||
|
|
8b6f4d2a45 | ||
|
|
cee4a2d7ae | ||
|
|
4bd5446a4e | ||
|
|
2f703b30db | ||
|
|
2f8d447d90 | ||
|
|
7ecc10b989 | ||
|
|
406b1813cf | ||
|
|
058dc2021d | ||
|
|
49a41a3f08 | ||
|
|
61848f980b | ||
|
|
962e312fdc | ||
|
|
4a6de520db | ||
|
|
9745bf309e | ||
|
|
2a847e52fa | ||
|
|
5953c07346 | ||
|
|
4ccfaa470d | ||
|
|
d1aa9a1fa1 | ||
|
|
bfca97f54d | ||
|
|
e79f0f364d | ||
|
|
2360370d19 | ||
|
|
b86226c2f6 | ||
|
|
f62a3b26fc | ||
|
|
5ffb286353 | ||
|
|
cacfe95c59 | ||
|
|
1fe6b24d47 | ||
|
|
d4d3d1a8e7 | ||
|
|
fd98f82a07 | ||
|
|
4e42b08f3c | ||
|
|
aef8bd5642 | ||
|
|
aa35b3f3fd | ||
|
|
295bdf3fa8 | ||
|
|
16f0580d33 | ||
|
|
0ecaecc889 | ||
|
|
8b07f4b059 | ||
|
|
98d098f060 | ||
|
|
05c5d2a12d | ||
|
|
e97ee306d8 | ||
|
|
461db01257 | ||
|
|
20562fb32a | ||
|
|
1e093f9cb6 | ||
|
|
bda77bc934 | ||
|
|
55bded5041 | ||
|
|
4fdb21e0ea | ||
|
|
c2ead29ff9 | ||
|
|
8590bb5727 | ||
|
|
d849a9e010 | ||
|
|
6fc28fcf2e | ||
|
|
75556460f0 | ||
|
|
80f6f04132 | ||
|
|
7e25675dc3 | ||
|
|
89e3728ec8 | ||
|
|
424c97464a | ||
|
|
c89176b219 | ||
|
|
1d2ad13bd8 | ||
|
|
d085b5911d | ||
|
|
6c3fc60e32 | ||
|
|
0bfab96fc0 | ||
|
|
de82d100d5 | ||
|
|
e79e4bb615 | ||
|
|
fc87cfaf37 | ||
|
|
512bcdd803 | ||
|
|
bda9c570c9 | ||
|
|
76a01254ed | ||
|
|
f4407fe651 | ||
|
|
8c6f4c2f92 | ||
|
|
3b0f5c45c2 | ||
|
|
4b09f0d49c | ||
|
|
dfdaae0409 | ||
|
|
bbf7ef8482 | ||
|
|
c9e9bc3529 | ||
|
|
7aa82e8547 | ||
|
|
d1a538b5fd | ||
|
|
75cab2ad13 | ||
|
|
3a4bc8a153 | ||
|
|
bc7bc46ffd | ||
|
|
aa8df89b20 | ||
|
|
2e889c82c8 | ||
|
|
9062937951 | ||
|
|
2fe6dcacbc | ||
|
|
6d5879177d | ||
|
|
9211e2222c | ||
|
|
977cd55d32 | ||
|
|
e0325c45d2 | ||
|
|
e88c50c70d | ||
|
|
24ffbd0c16 | ||
|
|
90b361a309 | ||
|
|
26e667a77c | ||
|
|
70ddccd88f | ||
|
|
6bc76a92ea | ||
|
|
74f478679f | ||
|
|
7b50ceb955 | ||
|
|
7fe3bfcb98 | ||
|
|
4aacf3f9a1 | ||
|
|
ea16fe9b24 | ||
|
|
f0883806c4 | ||
|
|
1aa4d93160 | ||
|
|
f5391d0621 | ||
|
|
4d1378b4b3 | ||
|
|
2790e8c339 | ||
|
|
1579545be2 | ||
|
|
f49b990e94 | ||
|
|
66b98ca025 | ||
|
|
92f9636ebe | ||
|
|
74eb3418b6 | ||
|
|
6ef9c176dd | ||
|
|
6bf836b719 | ||
|
|
1ce90ed355 | ||
|
|
90825277d3 | ||
|
|
95dc90e503 | ||
|
|
def9795c8f | ||
|
|
1e769d9263 | ||
|
|
c51257692d | ||
|
|
a33a127f81 | ||
|
|
1504e5ad89 | ||
|
|
a55d638690 | ||
|
|
88e774cb40 | ||
|
|
8e3dcf49ba | ||
|
|
f0c7a601c3 | ||
|
|
ce1d460d8a | ||
|
|
fc80f30981 | ||
|
|
ffe3ee3754 | ||
|
|
0147832a64 | ||
|
|
f2a1925033 | ||
|
|
d63213d463 | ||
|
|
68e39b624a | ||
|
|
ea54777dd2 | ||
|
|
34def78926 | ||
|
|
c744422d0e | ||
|
|
67b80e35f9 | ||
|
|
57ccbd4898 | ||
|
|
d4c1429ea7 | ||
|
|
ada2a87d8c | ||
|
|
6028ddb189 | ||
|
|
d9b2d50045 | ||
|
|
7f550c8bce | ||
|
|
a3ceafbcd0 | ||
|
|
d9a08801c5 | ||
|
|
0ca571f58c | ||
|
|
82249c99b3 | ||
|
|
ae3d14bef5 | ||
|
|
ec38c46ff6 | ||
|
|
13532f7768 | ||
|
|
0359e54999 | ||
|
|
b899c61bbc | ||
|
|
1aeb8a3305 | ||
|
|
99db066e2a | ||
|
|
2937f1988b | ||
|
|
d65511e328 | ||
|
|
601e49dc55 | ||
|
|
2232f9157c | ||
|
|
c09cb6e05a | ||
|
|
fe0809e2fa | ||
|
|
f21311b946 | ||
|
|
adff96b4cf | ||
|
|
43c2aab84b | ||
|
|
dc7cd7704f | ||
|
|
57f83933fd | ||
|
|
48b5f59b8e | ||
|
|
1b5ff4c86f | ||
|
|
963cd58ab6 | ||
|
|
f302fce89e | ||
|
|
5342f6f55a | ||
|
|
5f1624d6f5 | ||
|
|
447dd346c1 | ||
|
|
26f12734f8 | ||
|
|
67865368aa | ||
|
|
1fad0e2638 | ||
|
|
fe4253f872 | ||
|
|
a8dc349f01 | ||
|
|
79ec1506de | ||
|
|
e661b5a275 | ||
|
|
955a1fae98 | ||
|
|
ecda8ff57b | ||
|
|
ba56db81e1 | ||
|
|
8de5aa2fb4 | ||
|
|
64b297a180 | ||
|
|
0239efd826 |
@@ -0,0 +1,12 @@
|
||||
# http://editorconfig.org/
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = true
|
||||
@@ -1,22 +0,0 @@
|
||||
name: Contributor License Agreement (CLA)
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
cla:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event.issue.pull_request
|
||||
&& !github.event.issue.pull_request.merged_at
|
||||
&& contains(github.event.comment.body, 'signed')
|
||||
)
|
||||
|| (github.event.pull_request && !github.event.pull_request.merged)
|
||||
steps:
|
||||
- uses: Shopify/shopify-cla-action@v1
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
cla-token: ${{ secrets.CLA_TOKEN }}
|
||||
@@ -0,0 +1,20 @@
|
||||
name: Build Docs
|
||||
|
||||
on:
|
||||
push: {}
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.owner.login != 'Shopify'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '2.7.1'
|
||||
bundler-cache: true
|
||||
- run: bundle exec jekyll build --trace
|
||||
@@ -1,36 +0,0 @@
|
||||
name: Liquid
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
BUNDLE_JOBS: 4
|
||||
BUNDLE_RETRY: 3
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
entry:
|
||||
- { ruby: 3.0, allowed-failure: false } # minimum supported
|
||||
- { ruby: 3.2, allowed-failure: false }
|
||||
- { ruby: 3.3, allowed-failure: false } # latest
|
||||
- { ruby: ruby-head, allowed-failure: false }
|
||||
name: Test Ruby ${{ matrix.entry.ruby }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.entry.ruby }}
|
||||
bundler-cache: true
|
||||
bundler: latest
|
||||
- run: bundle exec rake
|
||||
continue-on-error: ${{ matrix.entry.allowed-failure }}
|
||||
|
||||
memory_profile:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
- run: bundle exec rake memory_profile:run
|
||||
+41
-8
@@ -1,9 +1,42 @@
|
||||
*~
|
||||
*.gem
|
||||
*.swp
|
||||
pkg
|
||||
*.rbc
|
||||
.rvmrc
|
||||
.bundle
|
||||
.byebug_history
|
||||
_site/
|
||||
.sass-cache/
|
||||
node_modules/
|
||||
Gemfile.lock
|
||||
|
||||
# Compiled source #
|
||||
###################
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
|
||||
# Packages #
|
||||
############
|
||||
# it's better to unpack these files and commit the raw source
|
||||
# git has its own built in compression methods
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
inherit_gem:
|
||||
rubocop-shopify: rubocop.yml
|
||||
|
||||
inherit_from:
|
||||
- .rubocop_todo.yml
|
||||
|
||||
require: rubocop-performance
|
||||
|
||||
Performance:
|
||||
Enabled: true
|
||||
|
||||
AllCops:
|
||||
NewCops: disable
|
||||
SuggestExtensions: false
|
||||
Exclude:
|
||||
- 'vendor/bundle/**/*'
|
||||
|
||||
Naming/MethodName:
|
||||
Exclude:
|
||||
- 'example/server/liquid_servlet.rb'
|
||||
|
||||
Style/ClassMethodsDefinitions:
|
||||
Enabled: false
|
||||
|
||||
# liquid filter calls were being mistaken to be calls on arrays
|
||||
Style/ConcatArrayLiterals:
|
||||
Exclude:
|
||||
- 'test/integration/standard_filter_test.rb'
|
||||
@@ -1,180 +0,0 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2022-05-18 19:25:47 UTC using RuboCop version 1.29.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
|
||||
# Include: **/*.gemspec
|
||||
Gemspec/OrderedDependencies:
|
||||
Exclude:
|
||||
- 'liquid.gemspec'
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
Layout/ClosingHeredocIndentation:
|
||||
Exclude:
|
||||
- 'test/integration/tags/for_tag_test.rb'
|
||||
|
||||
# Offense count: 34
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
Layout/EmptyLineAfterGuardClause:
|
||||
Exclude:
|
||||
- 'lib/liquid/block.rb'
|
||||
- 'lib/liquid/block_body.rb'
|
||||
- 'lib/liquid/context.rb'
|
||||
- 'lib/liquid/drop.rb'
|
||||
- 'lib/liquid/lexer.rb'
|
||||
- 'lib/liquid/parser.rb'
|
||||
- 'lib/liquid/profiler/hooks.rb'
|
||||
- 'lib/liquid/standardfilters.rb'
|
||||
- 'lib/liquid/tags/for.rb'
|
||||
- 'lib/liquid/tags/if.rb'
|
||||
- 'lib/liquid/utils.rb'
|
||||
- 'lib/liquid/variable.rb'
|
||||
- 'lib/liquid/variable_lookup.rb'
|
||||
- 'performance/shopify/money_filter.rb'
|
||||
- 'performance/shopify/paginate.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: AllowAliasSyntax, AllowedMethods.
|
||||
# AllowedMethods: alias_method, public, protected, private
|
||||
Layout/EmptyLinesAroundAttributeAccessor:
|
||||
Exclude:
|
||||
- 'lib/liquid/template.rb'
|
||||
- 'test/integration/filter_test.rb'
|
||||
- 'test/integration/tags/include_tag_test.rb'
|
||||
- 'test/unit/strainer_template_unit_test.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
Exclude:
|
||||
- 'test/integration/tags/for_tag_test.rb'
|
||||
- 'test/integration/tags/increment_tag_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented
|
||||
Layout/MultilineOperationIndentation:
|
||||
Exclude:
|
||||
- 'lib/liquid/expression.rb'
|
||||
|
||||
# Offense count: 9
|
||||
Lint/MissingSuper:
|
||||
Exclude:
|
||||
- 'lib/liquid/forloop_drop.rb'
|
||||
- 'lib/liquid/tablerowloop_drop.rb'
|
||||
- 'test/integration/assign_test.rb'
|
||||
- 'test/integration/context_test.rb'
|
||||
- 'test/integration/filter_test.rb'
|
||||
- 'test/integration/standard_filter_test.rb'
|
||||
- 'test/integration/tags/for_tag_test.rb'
|
||||
- 'test/integration/tags/table_row_test.rb'
|
||||
|
||||
# Offense count: 44
|
||||
Naming/ConstantName:
|
||||
Exclude:
|
||||
- 'lib/liquid.rb'
|
||||
- 'lib/liquid/block_body.rb'
|
||||
- 'lib/liquid/tags/assign.rb'
|
||||
- 'lib/liquid/tags/capture.rb'
|
||||
- 'lib/liquid/tags/case.rb'
|
||||
- 'lib/liquid/tags/cycle.rb'
|
||||
- 'lib/liquid/tags/for.rb'
|
||||
- 'lib/liquid/tags/if.rb'
|
||||
- 'lib/liquid/tags/raw.rb'
|
||||
- 'lib/liquid/tags/table_row.rb'
|
||||
- 'lib/liquid/variable.rb'
|
||||
- 'performance/shopify/comment_form.rb'
|
||||
- 'performance/shopify/paginate.rb'
|
||||
- 'test/integration/tags/include_tag_test.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Configuration parameters: CheckIdentifiers, CheckConstants, CheckVariables, CheckStrings, CheckSymbols, CheckComments, CheckFilepaths, FlaggedTerms.
|
||||
Naming/InclusiveLanguage:
|
||||
Exclude:
|
||||
- 'lib/liquid/drop.rb'
|
||||
- 'lib/liquid/parse_context.rb'
|
||||
- 'test/integration/drop_test.rb'
|
||||
- 'test/integration/tags/if_else_tag_test.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Style/ClassVars:
|
||||
Exclude:
|
||||
- 'lib/liquid/condition.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
Style/ExplicitBlockArgument:
|
||||
Exclude:
|
||||
- 'test/integration/context_test.rb'
|
||||
- 'test/integration/tag/disableable_test.rb'
|
||||
- 'test/integration/tags/for_tag_test.rb'
|
||||
|
||||
# Offense count: 2982
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
||||
# SupportedStyles: single_quotes, double_quotes
|
||||
Style/StringLiterals:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 20
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: single_quotes, double_quotes
|
||||
Style/StringLiteralsInInterpolation:
|
||||
Exclude:
|
||||
- 'lib/liquid/condition.rb'
|
||||
- 'lib/liquid/strainer_template.rb'
|
||||
- 'lib/liquid/tag/disableable.rb'
|
||||
- 'performance/shopify/shop_filter.rb'
|
||||
- 'performance/shopify/tag_filter.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyleForMultiline.
|
||||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
||||
Style/TrailingCommaInArrayLiteral:
|
||||
Exclude:
|
||||
- 'example/server/example_servlet.rb'
|
||||
- 'lib/liquid/condition.rb'
|
||||
- 'test/integration/context_test.rb'
|
||||
- 'test/integration/standard_filter_test.rb'
|
||||
- 'test/unit/parse_tree_visitor_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyleForMultiline.
|
||||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
Exclude:
|
||||
- 'lib/liquid/expression.rb'
|
||||
|
||||
# Offense count: 19
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
|
||||
# SupportedStyles: percent, brackets
|
||||
Style/WordArray:
|
||||
Exclude:
|
||||
- 'lib/liquid/tags/if.rb'
|
||||
- 'liquid.gemspec'
|
||||
- 'test/integration/assign_test.rb'
|
||||
- 'test/integration/context_test.rb'
|
||||
- 'test/integration/drop_test.rb'
|
||||
- 'test/integration/standard_filter_test.rb'
|
||||
|
||||
# Offense count: 117
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
Layout/LineLength:
|
||||
Max: 260
|
||||
@@ -1 +0,0 @@
|
||||
3.3.4
|
||||
@@ -1,28 +0,0 @@
|
||||
# How to contribute
|
||||
|
||||
## Things we will merge
|
||||
|
||||
* Bugfixes
|
||||
* Performance improvements
|
||||
* Features that are likely to be useful to the majority of Liquid users
|
||||
* Documentation updates that are concise and likely to be useful to the majority of Liquid users
|
||||
|
||||
## Things we won't merge
|
||||
|
||||
* Code that introduces considerable performance degrations
|
||||
* Code that touches performance-critical parts of Liquid and comes without benchmarks
|
||||
* Features that are not important for most people (we want to keep the core Liquid code small and tidy)
|
||||
* Features that can easily be implemented on top of Liquid (for example as a custom filter or custom filesystem)
|
||||
* Code that does not include tests
|
||||
* Code that breaks existing tests
|
||||
* Documentation changes that are verbose, incorrect or not important to most people (we want to keep it simple and easy to understand)
|
||||
|
||||
## Workflow
|
||||
|
||||
* [Sign the CLA](https://cla.shopify.com/) if you haven't already
|
||||
* Fork the Liquid repository
|
||||
* Create a new branch in your fork
|
||||
* For updating [Liquid documentation](https://shopify.github.io/liquid/), create it from `gh-pages` branch. (You can skip tests.)
|
||||
* If it makes sense, add tests for your code and/or run a performance benchmark
|
||||
* Make sure all tests pass (`bundle exec rake`)
|
||||
* Create a pull request
|
||||
@@ -1,30 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
git_source(:github) do |repo_name|
|
||||
"https://github.com/#{repo_name}.git"
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
||||
gem "base64"
|
||||
|
||||
group :benchmark, :test do
|
||||
gem 'benchmark-ips'
|
||||
gem 'memory_profiler'
|
||||
gem 'terminal-table'
|
||||
|
||||
install_if -> { RUBY_PLATFORM !~ /mingw|mswin|java/ && RUBY_ENGINE != 'truffleruby' } do
|
||||
gem 'stackprof'
|
||||
end
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'rubocop', '~> 1.61.0'
|
||||
gem 'rubocop-shopify', '~> 2.12.0', require: false
|
||||
gem 'rubocop-performance', require: false
|
||||
|
||||
platform :mri, :truffleruby do
|
||||
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'main'
|
||||
end
|
||||
end
|
||||
gem 'github-pages', '>=180', group: :jekyll_plugins
|
||||
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// Gruntfile
|
||||
module.exports = function (grunt) {
|
||||
require('load-grunt-tasks')(grunt)
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
watch: {
|
||||
css: {
|
||||
files: ['_sass/**/*.scss'],
|
||||
tasks: ['sass', 'postcss', 'shell:jekyllBuild'],
|
||||
options: {
|
||||
atBegin: true
|
||||
}
|
||||
},
|
||||
jekyll: {
|
||||
files: ['index.md', '_includes/*.html', 'filters/*.*', '_layouts/*.*', 'tags/*.*', 'basics/*.*'],
|
||||
tasks: ['shell:jekyllBuild']
|
||||
}
|
||||
},
|
||||
|
||||
sass: {
|
||||
dist: {
|
||||
options: {
|
||||
style: 'compact',
|
||||
sourcemap: 'none'
|
||||
},
|
||||
files: {
|
||||
'_site/css/main.css': '_sass/main.scss'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
shell: {
|
||||
jekyllServe: {
|
||||
command: 'bundle exec jekyll serve --no-watch'
|
||||
},
|
||||
|
||||
jekyllBuild: {
|
||||
command: 'bundle exec jekyll build'
|
||||
}
|
||||
},
|
||||
|
||||
postcss: {
|
||||
options: {
|
||||
map: true,
|
||||
processors: [
|
||||
require('autoprefixer')({browsers: 'last 2 versions'})
|
||||
]
|
||||
},
|
||||
dist: {
|
||||
src: '_site/css/*.css'
|
||||
}
|
||||
},
|
||||
|
||||
concurrent: {
|
||||
tasks: ['shell:jekyllServe', 'watch'],
|
||||
options: {
|
||||
logConcurrentOutput: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-watch')
|
||||
grunt.loadNpmTasks('grunt-contrib-sass')
|
||||
grunt.loadNpmTasks('grunt-postcss')
|
||||
grunt.loadNpmTasks('grunt-concurrent')
|
||||
|
||||
grunt.registerTask('default', ['concurrent'])
|
||||
}
|
||||
-381
@@ -1,381 +0,0 @@
|
||||
# Liquid Change Log
|
||||
|
||||
## 5.5.0 2024-03-21
|
||||
|
||||
Please reference the GitHub release for more information.
|
||||
|
||||
## 5.4.0 2022-07-29
|
||||
|
||||
### Breaking Changes
|
||||
* Drop support for end-of-life Ruby versions (2.5 and 2.6) (#1578) [Andy Waite]
|
||||
|
||||
### Features
|
||||
* Allow `#` to be used as an inline comment tag (#1498) [CP Clermont]
|
||||
|
||||
### Fixes
|
||||
* `PartialCache` now shares snippet cache with subcontexts by default (#1553) [Chris AtLee]
|
||||
* Hash registers no longer leak into subcontexts as static registers (#1564) [Chris AtLee]
|
||||
* Fix `ParseTreeVisitor` for `with` variable expressions in `Render` tag (#1596) [CP Clermont]
|
||||
|
||||
### Changed
|
||||
* Liquid::Context#registers now always returns a Liquid::Registers object, though supports the most used Hash functions for compatibility (#1553)
|
||||
|
||||
## 5.3.0 2022-03-22
|
||||
|
||||
### Fixes
|
||||
* StandardFilter: Fix missing @context on iterations (#1525) [Thierry Joyal]
|
||||
* Fix warning about block and default value in `static_registers.rb` (#1531) [Peter Zhu]
|
||||
|
||||
### Deprecation
|
||||
* Condition#evaluate to require mandatory context argument in Liquid 6.0.0 (#1527) [Thierry Joyal]
|
||||
|
||||
## 5.2.0 2022-03-01
|
||||
|
||||
### Features
|
||||
* Add `remove_last`, and `replace_last` filters (#1422) [Anders Hagbard]
|
||||
* Eagerly cache global filters (#1524) [Jean Boussier]
|
||||
|
||||
### Fixes
|
||||
* Fix some internal errors in filters from invalid input (#1476) [Dylan Thacker-Smith]
|
||||
* Allow dash in filter kwarg name for consistency with Liquid::C (#1518) [CP Clermont]
|
||||
|
||||
## 5.1.0 / 2021-09-09
|
||||
|
||||
### Features
|
||||
* Add `base64_encode`, `base64_decode`, `base64_url_safe_encode`, and `base64_url_safe_decode` filters (#1450) [Daniel Insley]
|
||||
* Introduce `to_liquid_value` in `Liquid::Drop` (#1441) [Michael Go]
|
||||
|
||||
### Fixes
|
||||
* Fix support for using a String subclass for the liquid source (#1421) [Dylan Thacker-Smith]
|
||||
* Add `ParseTreeVisitor` to `RangeLookup` (#1470) [CP Clermont]
|
||||
* Translate `RangeError` to `Liquid::Error` for `truncatewords` with large int (#1431) [Dylan Thacker-Smith]
|
||||
|
||||
## 5.0.1 / 2021-03-24
|
||||
|
||||
### Fixes
|
||||
* Add ParseTreeVisitor to Echo tag (#1414) [CP Clermont]
|
||||
* Test with ruby 3.0 as the latest ruby version (#1398) [Dylan Thacker-Smith]
|
||||
* Handle carriage return in newlines_to_br (#1391) [Unending]
|
||||
|
||||
### Performance Improvements
|
||||
* Use split limit in truncatewords (#1361) [Dylan Thacker-Smith]
|
||||
|
||||
## 5.0.0 / 2021-01-06
|
||||
|
||||
### Features
|
||||
* Add new `{% render %}` tag (#1122) [Samuel Doiron]
|
||||
* Add support for `as` in `{% render %}` and `{% include %}` (#1181) [Mike Angell]
|
||||
* Add `{% liquid %}` and `{% echo %}` tags (#1086) [Justin Li]
|
||||
* Add [usage tracking](README.md#usage-tracking) [Mike Angell]
|
||||
* Add `Tag.disable_tags` for disabling tags that prepend `Tag::Disableable` at render time (#1162, #1274, #1275) [Mike Angell]
|
||||
* Support using a profiler for multiple renders (#1365, #1366) [Dylan Thacker-Smith]
|
||||
|
||||
### Fixes
|
||||
* Fix catastrophic backtracking in `RANGES_REGEX` regular expression (#1357) [Dylan Thacker-Smith]
|
||||
* Make sure the for tag's limit and offset are integers (#1094) [David Cornu]
|
||||
* Invokable methods for enumerable reject include (#1151) [Thierry Joyal]
|
||||
* Allow `default` filter to handle `false` as value (#1144) [Mike Angell]
|
||||
* Fix render length resource limit so it doesn't multiply nested output (#1285) [Dylan Thacker-Smith]
|
||||
* Fix duplication of text in raw tags (#1304) [Peter Zhu]
|
||||
* Fix strict parsing of find variable with a name expression (#1317) [Dylan Thacker-Smith]
|
||||
* Use monotonic time to measure durations in Liquid::Profiler (#1362) [Dylan Thacker-Smith]
|
||||
|
||||
### Breaking Changes
|
||||
* Require Ruby >= 2.5 (#1131, #1310) [Mike Angell, Dylan Thacker-Smith]
|
||||
* Remove support for taint checking (#1268) [Dylan Thacker-Smith]
|
||||
* Split Strainer class into StrainerFactory and StrainerTemplate (#1208) [Thierry Joyal]
|
||||
* Remove handling of a nil context in the Strainer class (#1218) [Thierry Joyal]
|
||||
* Handle `BlockBody#blank?` at parse time (#1287) [Dylan Thacker-Smith]
|
||||
* Pass the tag markup and tokenizer to `Document#unknown_tag` (#1290) [Dylan Thacker-Smith]
|
||||
* And several internal changes
|
||||
|
||||
### Performance Improvements
|
||||
* Reduce allocations (#1073, #1091, #1115, #1099, #1117, #1141, #1322, #1341) [Richard Monette, Florian Weingarten, Ashwin Maroli]
|
||||
* Improve resources limits performance (#1093, #1323) [Florian Weingarten, Dylan Thacker-Smith]
|
||||
|
||||
## 4.0.3 / 2019-03-12
|
||||
|
||||
### Fixed
|
||||
* Fix break and continue tags inside included templates in loops (#1072) [Justin Li]
|
||||
|
||||
## 4.0.2 / 2019-03-08
|
||||
|
||||
### Changed
|
||||
* Add `where` filter (#1026) [Samuel Doiron]
|
||||
* Add `ParseTreeVisitor` to iterate the Liquid AST (#1025) [Stephen Paul Weber]
|
||||
* Improve `strip_html` performance (#1032) [printercu]
|
||||
|
||||
### Fixed
|
||||
* Add error checking for invalid combinations of inputs to sort, sort_natural, where, uniq, map, compact filters (#1059) [Garland Zhang]
|
||||
* Validate the character encoding in url_decode (#1070) [Clayton Smith]
|
||||
|
||||
## 4.0.1 / 2018-10-09
|
||||
|
||||
### Changed
|
||||
* Add benchmark group in Gemfile (#855) [Jerry Liu]
|
||||
* Allow benchmarks to benchmark render by itself (#851) [Jerry Liu]
|
||||
* Avoid calling `line_number` on String node when rescuing a render error. (#860) [Dylan Thacker-Smith]
|
||||
* Avoid duck typing to detect whether to call render on a node. [Dylan Thacker-Smith]
|
||||
* Clarify spelling of `reversed` on `for` block tag (#843) [Mark Crossfield]
|
||||
* Replace recursion with loop to avoid potential stack overflow from malicious input (#891, #892) [Dylan Thacker-Smith]
|
||||
* Limit block tag nesting to 100 (#894) [Dylan Thacker-Smith]
|
||||
* Replace `assert_equal nil` with `assert_nil` (#895) [Dylan Thacker-Smith]
|
||||
* Remove Spy Gem (#896) [Dylan Thacker-Smith]
|
||||
* Add `collection_name` and `variable_name` reader to `For` block (#909)
|
||||
* Symbols render as strings (#920) [Justin Li]
|
||||
* Remove default value from Hash objects (#932) [Maxime Bedard]
|
||||
* Remove one level of nesting (#944) [Dylan Thacker-Smith]
|
||||
* Update Rubocop version (#952) [Justin Li]
|
||||
* Add `at_least` and `at_most` filters (#954, #958) [Nithin Bekal]
|
||||
* Add a regression test for a liquid-c trim mode bug (#972) [Dylan Thacker-Smith]
|
||||
* Use https rather than git protocol to fetch liquid-c [Dylan Thacker-Smith]
|
||||
* Add tests against Ruby 2.4 (#963) and 2.5 (#981)
|
||||
* Replace RegExp literals with constants (#988) [Ashwin Maroli]
|
||||
* Replace unnecessary `#each_with_index` with `#each` (#992) [Ashwin Maroli]
|
||||
* Improve the unexpected end delimiter message for block tags. (#1003) [Dylan Thacker-Smith]
|
||||
* Refactor and optimize rendering (#1005) [Christopher Aue]
|
||||
* Add installation instruction (#1006) [Ben Gift]
|
||||
* Remove Circle CI (#1010)
|
||||
* Rename deprecated `BigDecimal.new` to `BigDecimal` (#1024) [Koichi ITO]
|
||||
* Rename deprecated Rubocop name (#1027) [Justin Li]
|
||||
|
||||
### Fixed
|
||||
* Handle `join` filter on non String joiners (#857) [Richard Monette]
|
||||
* Fix duplicate inclusion condition logic error of `Liquid::Strainer.add_filter` method (#861)
|
||||
* Fix `escape`, `url_encode`, `url_decode` not handling non-string values (#898) [Thierry Joyal]
|
||||
* Fix raise when variable is defined but nil when using `strict_variables` [Pascal Betz]
|
||||
* Fix `sort` and `sort_natural` to handle arrays with nils (#930) [Eric Chan]
|
||||
|
||||
## 4.0.0 / 2016-12-14 / branch "4-0-stable"
|
||||
|
||||
### Changed
|
||||
* Render an opaque internal error by default for non-Liquid::Error (#835) [Dylan Thacker-Smith]
|
||||
* Ruby 2.0 support dropped (#832) [Dylan Thacker-Smith]
|
||||
* Add to_number Drop method to allow custom drops to work with number filters (#731)
|
||||
* Add strict_variables and strict_filters options to detect undefined references (#691)
|
||||
* Improve loop performance (#681) [Florian Weingarten]
|
||||
* Rename Drop method `before_method` to `liquid_method_missing` (#661) [Thierry Joyal]
|
||||
* Add url_decode filter to invert url_encode (#645) [Larry Archer]
|
||||
* Add global_filter to apply a filter to all output (#610) [Loren Hale]
|
||||
* Add compact filter (#600) [Carson Reinke]
|
||||
* Rename deprecated "has_key?" and "has_interrupt?" methods (#593) [Florian Weingarten]
|
||||
* Include template name with line numbers in render errors (574) [Dylan Thacker-Smith]
|
||||
* Add sort_natural filter (#554) [Martin Hanzel]
|
||||
* Add forloop.parentloop as a reference to the parent loop (#520) [Justin Li]
|
||||
* Block parsing moved to BlockBody class (#458) [Dylan Thacker-Smith]
|
||||
* Add concat filter to concatenate arrays (#429) [Diogo Beato]
|
||||
* Ruby 1.9 support dropped (#491) [Justin Li]
|
||||
* Liquid::Template.file_system's read_template_file method is no longer passed the context. (#441) [James Reid-Smith]
|
||||
* Remove `liquid_methods` (See https://github.com/Shopify/liquid/pull/568 for replacement)
|
||||
* Liquid::Template.register_filter raises when the module overrides registered public methods as private or protected (#705) [Gaurav Chande]
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix variable names being detected as an operator when starting with contains (#788) [Michael Angell]
|
||||
* Fix include tag used with strict_variables (#828) [QuickPay]
|
||||
* Fix map filter when value is a Proc (#672) [Guillaume Malette]
|
||||
* Fix truncate filter when value is not a string (#672) [Guillaume Malette]
|
||||
* Fix behaviour of escape filter when input is nil (#665) [Tanel Jakobsoo]
|
||||
* Fix sort filter behaviour with empty array input (#652) [Marcel Cary]
|
||||
* Fix test failure under certain timezones (#631) [Dylan Thacker-Smith]
|
||||
* Fix bug in uniq filter (#595) [Florian Weingarten]
|
||||
* Fix bug when "blank" and "empty" are used as variable names (#592) [Florian Weingarten]
|
||||
* Fix condition parse order in strict mode (#569) [Justin Li]
|
||||
* Fix naming of the "context variable" when dynamically including a template (#559) [Justin Li]
|
||||
* Gracefully accept empty strings in the date filter (#555) [Loren Hale]
|
||||
* Fix capturing into variables with a hyphen in the name (#505) [Florian Weingarten]
|
||||
* Fix case sensitivity regression in date standard filter (#499) [Kelley Reynolds]
|
||||
* Disallow filters with no variable in strict mode (#475) [Justin Li]
|
||||
* Disallow variable names in the strict parser that are not valid in the lax parser (#463) [Justin Li]
|
||||
* Fix BlockBody#warnings taking exponential time to compute (#486) [Justin Li]
|
||||
|
||||
## 3.0.5 / 2015-07-23 / branch "3-0-stable"
|
||||
|
||||
* Fix test failure under certain timezones [Dylan Thacker-Smith]
|
||||
|
||||
## 3.0.4 / 2015-07-17
|
||||
|
||||
* Fix chained access to multi-dimensional hashes [Florian Weingarten]
|
||||
|
||||
## 3.0.3 / 2015-05-28
|
||||
|
||||
* Fix condition parse order in strict mode (#569) [Justin Li]
|
||||
|
||||
## 3.0.2 / 2015-04-24
|
||||
|
||||
* Expose VariableLookup private members (#551) [Justin Li]
|
||||
* Documentation fixes
|
||||
|
||||
## 3.0.1 / 2015-01-23
|
||||
|
||||
* Remove duplicate `index0` key in TableRow tag (#502) [Alfred Xing]
|
||||
|
||||
## 3.0.0 / 2014-11-12
|
||||
|
||||
* Removed Block#end_tag. Instead, override parse with `super` followed by your code. See #446 [Dylan Thacker-Smith]
|
||||
* Fixed condition with wrong data types (#423) [Bogdan Gusiev]
|
||||
* Add url_encode to standard filters (#421) [Derrick Reimer]
|
||||
* Add uniq to standard filters [Florian Weingarten]
|
||||
* Add exception_handler feature (#397) and #254 [Bogdan Gusiev, Florian Weingarten]
|
||||
* Optimize variable parsing to avoid repeated regex evaluation during template rendering #383 [Jason Hiltz-Laforge]
|
||||
* Optimize checking for block interrupts to reduce object allocation #380 [Jason Hiltz-Laforge]
|
||||
* Properly set context rethrow_errors on render! #349 [Thierry Joyal]
|
||||
* Fix broken rendering of variables which are equal to false (#345) [Florian Weingarten]
|
||||
* Remove ActionView template handler [Dylan Thacker-Smith]
|
||||
* Freeze lots of string literals for new Ruby 2.1 optimization (#297) [Florian Weingarten]
|
||||
* Allow newlines in tags and variables (#324) [Dylan Thacker-Smith]
|
||||
* Tag#parse is called after initialize, which now takes options instead of tokens as the 3rd argument. See #321 [Dylan Thacker-Smith]
|
||||
* Raise `Liquid::ArgumentError` instead of `::ArgumentError` when filter has wrong number of arguments #309 [Bogdan Gusiev]
|
||||
* Add a to_s default for liquid drops (#306) [Adam Doeler]
|
||||
* Add strip, lstrip, and rstrip to standard filters [Florian Weingarten]
|
||||
* Make if, for & case tags return complete and consistent nodelists (#250) [Nick Jones]
|
||||
* Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith]
|
||||
* Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl]
|
||||
* Fix resource counting bug with respond_to?(:length) (#263) [Florian Weingarten]
|
||||
* Allow specifying custom patterns for template filenames (#284) [Andrei Gladkyi]
|
||||
* Allow drops to optimize loading a slice of elements (#282) [Tom Burns]
|
||||
* Support for passing variables to snippets in subdirs (#271) [Joost Hietbrink]
|
||||
* Add a class cache to avoid runtime extend calls (#249) [James Tucker]
|
||||
* Remove some legacy Ruby 1.8 compatibility code (#276) [Florian Weingarten]
|
||||
* Add default filter to standard filters (#267) [Derrick Reimer]
|
||||
* Add optional strict parsing and warn parsing (#235) [Tristan Hume]
|
||||
* Add I18n syntax error translation (#241) [Simon Hørup Eskildsen, Sirupsen]
|
||||
* Make sort filter work on enumerable drops (#239) [Florian Weingarten]
|
||||
* Fix clashing method names in enumerable drops (#238) [Florian Weingarten]
|
||||
* Make map filter work on enumerable drops (#233) [Florian Weingarten]
|
||||
* Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten]
|
||||
|
||||
## 2.6.3 / 2015-07-23 / branch "2-6-stable"
|
||||
|
||||
* Fix test failure under certain timezones [Dylan Thacker-Smith]
|
||||
|
||||
## 2.6.2 / 2015-01-23
|
||||
|
||||
* Remove duplicate hash key [Parker Moore]
|
||||
|
||||
## 2.6.1 / 2014-01-10
|
||||
|
||||
Security fix, cherry-picked from master (4e14a65):
|
||||
* Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl]
|
||||
* Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith]
|
||||
|
||||
## 2.6.0 / 2013-11-25
|
||||
|
||||
IMPORTANT: Liquid 2.6 is going to be the last version of Liquid which maintains explicit Ruby 1.8 compatability.
|
||||
The following releases will only be tested against Ruby 1.9 and Ruby 2.0 and are likely to break on Ruby 1.8.
|
||||
|
||||
* Bugfix for #106: fix example servlet [gnowoel]
|
||||
* Bugfix for #97: strip_html filter supports multi-line tags [Jo Liss]
|
||||
* Bugfix for #114: strip_html filter supports style tags [James Allardice]
|
||||
* Bugfix for #117: 'now' support for date filter in Ruby 1.9 [Notre Dame Webgroup]
|
||||
* Bugfix for #166: truncate filter on UTF-8 strings with Ruby 1.8 [Florian Weingarten]
|
||||
* Bugfix for #204: 'raw' parsing bug [Florian Weingarten]
|
||||
* Bugfix for #150: 'for' parsing bug [Peter Schröder]
|
||||
* Bugfix for #126: Strip CRLF in strip_newline [Peter Schröder]
|
||||
* Bugfix for #174, "can't convert Fixnum into String" for "replace" [jsw0528]
|
||||
* Allow a Liquid::Drop to be passed into Template#render [Daniel Huckstep]
|
||||
* Resource limits [Florian Weingarten]
|
||||
* Add reverse filter [Jay Strybis]
|
||||
* Add utf-8 support
|
||||
* Use array instead of Hash to keep the registered filters [Tasos Stathopoulos]
|
||||
* Cache tokenized partial templates [Tom Burns]
|
||||
* Avoid warnings in Ruby 1.9.3 [Marcus Stollsteimer]
|
||||
* Better documentation for 'include' tag (closes #163) [Peter Schröder]
|
||||
* Use of BigDecimal on filters to have better precision (closes #155) [Arthur Nogueira Neves]
|
||||
|
||||
## 2.5.5 / 2014-01-10 / branch "2-5-stable"
|
||||
|
||||
Security fix, cherry-picked from master (4e14a65):
|
||||
* Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl]
|
||||
* Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith]
|
||||
|
||||
## 2.5.4 / 2013-11-11
|
||||
|
||||
* Fix "can't convert Fixnum into String" for "replace" (#173), [jsw0528]
|
||||
|
||||
## 2.5.3 / 2013-10-09
|
||||
|
||||
* #232, #234, #237: Fix map filter bugs [Florian Weingarten]
|
||||
|
||||
## 2.5.2 / 2013-09-03 / deleted
|
||||
|
||||
Yanked from rubygems, as it contained too many changes that broke compatibility. Those changes will be on following major releases.
|
||||
|
||||
## 2.5.1 / 2013-07-24
|
||||
|
||||
* #230: Fix security issue with map filter, Use invoke_drop in map filter [Florian Weingarten]
|
||||
|
||||
## 2.5.0 / 2013-03-06
|
||||
|
||||
* Prevent Object methods from being called on drops
|
||||
* Avoid symbol injection from liquid
|
||||
* Added break and continue statements
|
||||
* Fix filter parser for args without space separators
|
||||
* Add support for filter keyword arguments
|
||||
|
||||
|
||||
## 2.4.0 / 2012-08-03
|
||||
|
||||
* Performance improvements
|
||||
* Allow filters in `assign`
|
||||
* Add `modulo` filter
|
||||
* Ruby 1.8, 1.9, and Rubinius compatibility fixes
|
||||
* Add support for `quoted['references']` in `tablerow`
|
||||
* Add support for Enumerable to `tablerow`
|
||||
* `strip_html` filter removes html comments
|
||||
|
||||
|
||||
## 2.3.0 / 2011-10-16
|
||||
|
||||
* Several speed/memory improvements
|
||||
* Numerous bug fixes
|
||||
* Added support for MRI 1.9, Rubinius, and JRuby
|
||||
* Added support for integer drop parameters
|
||||
* Added epoch support to `date` filter
|
||||
* New `raw` tag that suppresses parsing
|
||||
* Added `else` option to `for` tag
|
||||
* New `increment` tag
|
||||
* New `split` filter
|
||||
|
||||
|
||||
## 2.2.1 / 2010-08-23
|
||||
|
||||
* Added support for literal tags
|
||||
|
||||
|
||||
## 2.2.0 / 2010-08-22
|
||||
|
||||
* Compatible with Ruby 1.8.7, 1.9.1 and 1.9.2-p0
|
||||
* Merged some changed made by the community
|
||||
|
||||
|
||||
## 1.9.0 / 2008-03-04
|
||||
|
||||
* Fixed gem install rake task
|
||||
* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins
|
||||
|
||||
|
||||
## Before 1.9.0
|
||||
|
||||
* Added If with or / and expressions
|
||||
* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods.
|
||||
* Added more tags to standard library
|
||||
* Added include tag ( like partials in rails )
|
||||
* [...] Gazillion of detail improvements
|
||||
* Added strainers as filter hosts for better security [Tobias Luetke]
|
||||
* Fixed that rails integration would call filter with the wrong "self" [Michael Geary]
|
||||
* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke]
|
||||
* Removed count helper from standard lib. use size [Tobias Luetke]
|
||||
* Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond]
|
||||
* Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond]
|
||||
{{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }}
|
||||
* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke]
|
||||
|
||||
class ProductDrop < Liquid::Drop
|
||||
def top_sales
|
||||
Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
|
||||
end
|
||||
end
|
||||
t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' )
|
||||
t.render('product' => ProductDrop.new )
|
||||
* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond]
|
||||
@@ -1,20 +0,0 @@
|
||||
Copyright (c) 2005, 2006 Tobias Luetke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,156 +1,11 @@
|
||||
[](https://github.com/Shopify/liquid/actions/workflows/liquid.yml)
|
||||
[](http://inch-ci.org/github/Shopify/liquid)
|
||||
# New Liquid Docs
|
||||
|
||||
# Liquid template engine
|
||||
To run, follow these steps:
|
||||
|
||||
* [Contributing guidelines](CONTRIBUTING.md)
|
||||
* [Version history](History.md)
|
||||
* [Liquid documentation from Shopify](https://shopify.dev/docs/api/liquid)
|
||||
* [Liquid Wiki at GitHub](https://github.com/Shopify/liquid/wiki)
|
||||
* [Website](http://liquidmarkup.org/)
|
||||
|
||||
## Introduction
|
||||
|
||||
Liquid is a template engine which was written with very specific requirements:
|
||||
|
||||
* It has to have beautiful and simple markup. Template engines which don't produce good looking markup are no fun to use.
|
||||
* It needs to be non evaling and secure. Liquid templates are made so that users can edit them. You don't want to run code on your server which your users wrote.
|
||||
* It has to be stateless. Compile and render steps have to be separate so that the expensive parsing and compiling can be done once and later on you can just render it passing in a hash with local variables and objects.
|
||||
|
||||
## Why you should use Liquid
|
||||
|
||||
* You want to allow your users to edit the appearance of your application but don't want them to run **insecure code on your server**.
|
||||
* You want to render templates directly from the database.
|
||||
* You like smarty (PHP) style template engines.
|
||||
* You need a template engine which does HTML just as well as emails.
|
||||
* You don't like the markup of your current templating engine.
|
||||
|
||||
## What does it look like?
|
||||
|
||||
```html
|
||||
<ul id="products">
|
||||
{% for product in products %}
|
||||
<li>
|
||||
<h2>{{ product.name }}</h2>
|
||||
Only {{ product.price | price }}
|
||||
|
||||
{{ product.description | prettyprint | paragraph }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
||||
## How to use Liquid
|
||||
|
||||
Install Liquid by adding `gem 'liquid'` to your gemfile.
|
||||
|
||||
Liquid supports a very simple API based around the Liquid::Template class.
|
||||
For standard use you can just pass it the content of a file and call render with a parameters hash.
|
||||
|
||||
```ruby
|
||||
@template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
|
||||
@template.render('name' => 'tobi') # => "hi tobi"
|
||||
```
|
||||
|
||||
### Concept of Environments
|
||||
|
||||
In Liquid, a "Environment" is a scoped environment that encapsulates custom tags, filters, and other configurations. This allows you to define and isolate different sets of functionality for different contexts, avoiding global overrides that can lead to conflicts and unexpected behavior.
|
||||
|
||||
By using environments, you can:
|
||||
|
||||
1. **Encapsulate Logic**: Keep the logic for different parts of your application separate.
|
||||
2. **Avoid Conflicts**: Prevent custom tags and filters from clashing with each other.
|
||||
3. **Improve Maintainability**: Make it easier to manage and understand the scope of customizations.
|
||||
4. **Enhance Security**: Limit the availability of certain tags and filters to specific contexts.
|
||||
|
||||
We encourage the use of Environments over globally overriding things because it promotes better software design principles such as modularity, encapsulation, and separation of concerns.
|
||||
|
||||
Here's an example of how you can define and use Environments in Liquid:
|
||||
|
||||
```ruby
|
||||
user_environment = Liquid::Environment.build do |environment|
|
||||
environment.register_tag("renderobj", RenderObjTag)
|
||||
end
|
||||
|
||||
Liquid::Template.parse(<<~LIQUID, environment: user_environment)
|
||||
{% renderobj src: "path/to/model.obj" %}
|
||||
LIQUID
|
||||
```
|
||||
|
||||
In this example, `RenderObjTag` is a custom tag that is only available within the `user_environment`.
|
||||
|
||||
Similarly, you can define another environment for a different context, such as email templates:
|
||||
|
||||
```ruby
|
||||
email_environment = Liquid::Environment.build do |environment|
|
||||
environment.register_tag("unsubscribe_footer", UnsubscribeFooter)
|
||||
end
|
||||
|
||||
Liquid::Template.parse(<<~LIQUID, environment: email_environment)
|
||||
{% unsubscribe_footer %}
|
||||
LIQUID
|
||||
```
|
||||
|
||||
By using Environments, you ensure that custom tags and filters are only available in the contexts where they are needed, making your Liquid templates more robust and easier to manage.
|
||||
|
||||
### Error Modes
|
||||
|
||||
Setting the error mode of Liquid lets you specify how strictly you want your templates to be interpreted.
|
||||
Normally the parser is very lax and will accept almost anything without error. Unfortunately this can make
|
||||
it very hard to debug and can lead to unexpected behaviour.
|
||||
|
||||
Liquid also comes with a stricter parser that can be used when editing templates to give better error messages
|
||||
when templates are invalid. You can enable this new parser like this:
|
||||
|
||||
```ruby
|
||||
Liquid::Environment.default.error_mode = :strict
|
||||
Liquid::Environment.default.error_mode = :strict # Raises a SyntaxError when invalid syntax is used
|
||||
Liquid::Environment.default.error_mode = :warn # Adds strict errors to template.errors but continues as normal
|
||||
Liquid::Environment.default.error_mode = :lax # The default mode, accepts almost anything.
|
||||
```
|
||||
|
||||
If you want to set the error mode only on specific templates you can pass `:error_mode` as an option to `parse`:
|
||||
```ruby
|
||||
Liquid::Template.parse(source, error_mode: :strict)
|
||||
```
|
||||
This is useful for doing things like enabling strict mode only in the theme editor.
|
||||
|
||||
It is recommended that you enable `:strict` or `:warn` mode on new apps to stop invalid templates from being created.
|
||||
It is also recommended that you use it in the template editors of existing apps to give editors better error messages.
|
||||
|
||||
### Undefined variables and filters
|
||||
|
||||
By default, the renderer doesn't raise or in any other way notify you if some variables or filters are missing, i.e. not passed to the `render` method.
|
||||
You can improve this situation by passing `strict_variables: true` and/or `strict_filters: true` options to the `render` method.
|
||||
When one of these options is set to true, all errors about undefined variables and undefined filters will be stored in `errors` array of a `Liquid::Template` instance.
|
||||
Here are some examples:
|
||||
|
||||
```ruby
|
||||
template = Liquid::Template.parse("{{x}} {{y}} {{z.a}} {{z.b}}")
|
||||
template.render({ 'x' => 1, 'z' => { 'a' => 2 } }, { strict_variables: true })
|
||||
#=> '1 2 ' # when a variable is undefined, it's rendered as nil
|
||||
template.errors
|
||||
#=> [#<Liquid::UndefinedVariable: Liquid error: undefined variable y>, #<Liquid::UndefinedVariable: Liquid error: undefined variable b>]
|
||||
```
|
||||
|
||||
```ruby
|
||||
template = Liquid::Template.parse("{{x | filter1 | upcase}}")
|
||||
template.render({ 'x' => 'foo' }, { strict_filters: true })
|
||||
#=> '' # when at least one filter in the filter chain is undefined, a whole expression is rendered as nil
|
||||
template.errors
|
||||
#=> [#<Liquid::UndefinedFilter: Liquid error: undefined filter filter1>]
|
||||
```
|
||||
|
||||
If you want to raise on a first exception instead of pushing all of them in `errors`, you can use `render!` method:
|
||||
|
||||
```ruby
|
||||
template = Liquid::Template.parse("{{x}} {{y}}")
|
||||
template.render!({ 'x' => 1}, { strict_variables: true })
|
||||
#=> Liquid::UndefinedVariable: Liquid error: undefined variable y
|
||||
```
|
||||
|
||||
### Usage tracking
|
||||
|
||||
To help track usages of a feature or code path in production, we have released opt-in usage tracking. To enable this, we provide an empty `Liquid:: Usage.increment` method which you can customize to your needs. The feature is well suited to https://github.com/Shopify/statsd-instrument. However, the choice of implementation is up to you.
|
||||
|
||||
Once you have enabled usage tracking, we recommend reporting any events through Github Issues that your system may be logging. It is highly likely this event has been added to consider deprecating or improving code specific to this event, so please raise any concerns.
|
||||
1. [Download and install Ruby](https://www.ruby-lang.org/en/downloads)
|
||||
2. Download ZIP or clone in GitHub
|
||||
3. Navigate to `liquid-gh-pages` folder or checkout `gh-pages` branch
|
||||
4. Run `gem install bundler`
|
||||
5. Run `bundle install`
|
||||
6. Run `bundle exec jekyll serve`
|
||||
7. Open [`http://127.0.0.1:4000/liquid/`](http://127.0.0.1:4000/liquid/) in your browser
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
|
||||
require "liquid/version"
|
||||
|
||||
task(default: [:test, :rubocop])
|
||||
|
||||
desc('run test suite with default parser')
|
||||
Rake::TestTask.new(:base_test) do |t|
|
||||
t.libs << 'lib' << 'test'
|
||||
t.test_files = FileList['test/{integration,unit}/**/*_test.rb']
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:integration_test) do |t|
|
||||
t.libs << 'lib' << 'test'
|
||||
t.test_files = FileList['test/integration/**/*_test.rb']
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
desc('run test suite with warn error mode')
|
||||
task :warn_test do
|
||||
ENV['LIQUID_PARSER_MODE'] = 'warn'
|
||||
Rake::Task['base_test'].invoke
|
||||
end
|
||||
|
||||
task :rubocop do
|
||||
if RUBY_ENGINE == 'ruby'
|
||||
require 'rubocop/rake_task'
|
||||
RuboCop::RakeTask.new
|
||||
end
|
||||
end
|
||||
|
||||
desc('runs test suite with both strict and lax parsers')
|
||||
task :test do
|
||||
ENV['LIQUID_PARSER_MODE'] = 'lax'
|
||||
Rake::Task['base_test'].invoke
|
||||
|
||||
ENV['LIQUID_PARSER_MODE'] = 'strict'
|
||||
Rake::Task['base_test'].reenable
|
||||
Rake::Task['base_test'].invoke
|
||||
|
||||
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'truffleruby'
|
||||
ENV['LIQUID_C'] = '1'
|
||||
|
||||
ENV['LIQUID_PARSER_MODE'] = 'lax'
|
||||
Rake::Task['integration_test'].reenable
|
||||
Rake::Task['integration_test'].invoke
|
||||
|
||||
ENV['LIQUID_PARSER_MODE'] = 'strict'
|
||||
Rake::Task['integration_test'].reenable
|
||||
Rake::Task['integration_test'].invoke
|
||||
end
|
||||
end
|
||||
|
||||
task(gem: :build)
|
||||
task :build do
|
||||
system "gem build liquid.gemspec"
|
||||
end
|
||||
|
||||
task install: :build do
|
||||
system "gem install liquid-#{Liquid::VERSION}.gem"
|
||||
end
|
||||
|
||||
task release: :build do
|
||||
system "git tag -a v#{Liquid::VERSION} -m 'Tagging #{Liquid::VERSION}'"
|
||||
system "git push --tags"
|
||||
system "gem push liquid-#{Liquid::VERSION}.gem"
|
||||
system "rm liquid-#{Liquid::VERSION}.gem"
|
||||
end
|
||||
|
||||
namespace :benchmark do
|
||||
desc "Run the liquid benchmark with lax parsing"
|
||||
task :run do
|
||||
ruby "./performance/benchmark.rb lax"
|
||||
end
|
||||
|
||||
desc "Run the liquid benchmark with strict parsing"
|
||||
task :strict do
|
||||
ruby "./performance/benchmark.rb strict"
|
||||
end
|
||||
|
||||
desc "Run unit benchmarks"
|
||||
task :unit do
|
||||
Dir["./performance/unit/*_benchmark.rb"].each do |file|
|
||||
puts "🧪 Running #{file}"
|
||||
ruby file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :profile do
|
||||
desc "Run the liquid profile/performance coverage"
|
||||
task :run do
|
||||
ruby "./performance/profile.rb"
|
||||
end
|
||||
|
||||
desc "Run the liquid profile/performance coverage with strict parsing"
|
||||
task :strict do
|
||||
ruby "./performance/profile.rb strict"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :memory_profile do
|
||||
desc "Run memory profiler"
|
||||
task :run do
|
||||
ruby "./performance/memory_profile.rb"
|
||||
end
|
||||
end
|
||||
|
||||
desc("Run example")
|
||||
task :example do
|
||||
ruby "-w -d -Ilib example/server/server.rb"
|
||||
end
|
||||
|
||||
task :console do
|
||||
exec 'irb -I lib -r liquid'
|
||||
end
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
title: Introduction
|
||||
description: An overview of objects, tags, and filters in the Liquid template language.
|
||||
redirect_from: /basics/
|
||||
---
|
||||
|
||||
Liquid uses a combination of [**objects**](#objects), [**tags**](#tags), and [**filters**](#filters) inside **template files** to display dynamic content.
|
||||
|
||||
## Objects
|
||||
|
||||
**Objects** contain the content that Liquid displays on a page. Objects and variables are displayed when enclosed in double curly braces: `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ page.title }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ page.title }}
|
||||
```
|
||||
|
||||
In this case, Liquid is rendering the content of the `title` property of the `page` object, which contains the text `{{ page.title }}`.
|
||||
|
||||
## Tags
|
||||
|
||||
**Tags** create the logic and control flow for templates. The curly brace percentage delimiters `{% raw %}{%{% endraw %}` and `{% raw %}%}{% endraw %}` and the text that they surround do not produce any visible output when the template is rendered. This lets you assign variables and create conditions or loops without showing any of the Liquid logic on the page.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if user %}
|
||||
Hello {{ user.name }}!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Hello Adam!
|
||||
```
|
||||
|
||||
Tags can be categorized into various types:
|
||||
|
||||
- [Control flow]({{ "/tags/control-flow/" | prepend: site.baseurl }})
|
||||
- [Iteration]({{ "/tags/iteration/" | prepend: site.baseurl }})
|
||||
- [Template]({{ "/tags/template/" | prepend: site.baseurl }})
|
||||
- [Variable assignment]({{ "/tags/variable/" | prepend: site.baseurl }})
|
||||
|
||||
You can read more about each type of tag in their respective sections.
|
||||
|
||||
## Filters
|
||||
|
||||
**Filters** change the output of a Liquid object or variable. They are used within double curly braces `{% raw %}{{ }}{% endraw %}` and [variable assignment]({{ "/tags/variable/" | prepend: site.baseurl }}), and are separated by a pipe character `|`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
```
|
||||
|
||||
Multiple filters can be used on one output, and are applied from left to right.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "adam!" | capitalize | prepend: "Hello " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "adam!" | capitalize | prepend: "Hello " }}
|
||||
```
|
||||
@@ -0,0 +1,114 @@
|
||||
---
|
||||
title: Operators
|
||||
description: Using operators to perform calculations in the Liquid template language.
|
||||
---
|
||||
|
||||
Liquid includes many logical and comparison operators. You can use operators to create logic with [control flow]({{ "/tags/control-flow/" | prepend: site.baseurl }}) tags.
|
||||
|
||||
## Basic operators
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>==</code></td>
|
||||
<td>equals</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>!=</code></td>
|
||||
<td>does not equal</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>></code></td>
|
||||
<td>greater than</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><</code></td>
|
||||
<td>less than</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>>=</code></td>
|
||||
<td>greater than or equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><=</code></td>
|
||||
<td>less than or equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>or</code></td>
|
||||
<td>logical or</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>and</code></td>
|
||||
<td>logical and</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
For example:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if product.title == "Awesome Shoes" %}
|
||||
These shoes are awesome!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
You can do multiple comparisons in a tag using the `and` and `or` operators:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if product.type == "Shirt" or product.type == "Shoes" %}
|
||||
This is a shirt or a pair of shoes.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## contains
|
||||
|
||||
`contains` checks for the presence of a substring inside a string.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if product.title contains "Pack" %}
|
||||
This product's title contains the word Pack.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
`contains` can also check for the presence of a string in an array of strings.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if product.tags contains "Hello" %}
|
||||
This product has been tagged with "Hello".
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
`contains` can only search strings. You cannot use it to check for an object in an array of objects.
|
||||
|
||||
## Order of operations
|
||||
|
||||
In tags with more than one `and` or `or` operator, operators are checked in order *from right to left*. You cannot change the order of operations using parentheses — parentheses are invalid characters in Liquid and will prevent your tags from working.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if true or false and false %}
|
||||
This evaluates to true, since the `and` condition is checked first.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if true and false and false or true %}
|
||||
This evaluates to false, since the tags are checked like this:
|
||||
|
||||
true and (false and (false or true))
|
||||
true and (false and true)
|
||||
true and false
|
||||
false
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: Truthy and falsy
|
||||
description: An overview of boolean logic in the Liquid template language.
|
||||
---
|
||||
|
||||
When a non-boolean [data type]({{ "/basics/types/" | prepend: site.baseurl }}) is used in a boolean context (such as a conditional tag), Liquid decides whether to evaluate it as `true` or `false`. Data types that return `true` by default are called **truthy**. Data types that return false by default are called **falsy**.
|
||||
|
||||
## Truthy
|
||||
|
||||
All values in Liquid are truthy except `nil` and `false`.
|
||||
|
||||
In the example below, the text "Tobi" is not a boolean, but it is truthy in a conditional:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign name = "Tobi" %}
|
||||
|
||||
{% if name %}
|
||||
This text will always appear since "name" is defined.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
[Strings]({{ "/basics/types/#string" | prepend: site.baseurl }}), even when empty, are truthy. The example below will create empty HTML tags if `page.category` exists but is empty:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if page.category %}
|
||||
<h1>{{ page.category }}</h1>
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```html
|
||||
<h1></h1>
|
||||
```
|
||||
|
||||
## Falsy
|
||||
|
||||
The only values that are falsy in Liquid are [`nil`]({{ "/basics/types/#nil" | prepend: site.baseurl }}) and [`false`]({{ "/basics/types/#boolean" | prepend: site.baseurl }}).
|
||||
|
||||
## Summary
|
||||
|
||||
The table below summarizes what is truthy or falsy in Liquid.
|
||||
|
||||
| | truthy | falsy |
|
||||
| ------------- |:-------------:|:-------------:|
|
||||
| true | • | |
|
||||
| false | | • |
|
||||
| nil | | • |
|
||||
| string | • | |
|
||||
| empty string | • | |
|
||||
| 0 | • | |
|
||||
| integer | • | |
|
||||
| float | • | |
|
||||
| array | • | |
|
||||
| empty array | • | |
|
||||
| page | • | |
|
||||
| EmptyDrop | • | |
|
||||
@@ -0,0 +1,157 @@
|
||||
---
|
||||
title: Types
|
||||
description: An overview of data types in the Liquid template language.
|
||||
---
|
||||
|
||||
Liquid objects can be one of six types:
|
||||
|
||||
- [String](#string)
|
||||
- [Number](#number)
|
||||
- [Boolean](#boolean)
|
||||
- [Nil](#nil)
|
||||
- [Array](#array)
|
||||
- [EmptyDrop](#emptydrop)
|
||||
|
||||
You can initialize Liquid variables using [`assign`]({{ "/tags/variable/#assign" | prepend: site.baseurl }}) or [`capture`]({{ "/tags/variable/#capture" | prepend: site.baseurl }}) tags.
|
||||
|
||||
## String
|
||||
|
||||
Strings are sequences of characters wrapped in single or double quotes:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_string = "Hello World!" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Liquid does not convert escape sequences into special characters.
|
||||
|
||||
## Number
|
||||
|
||||
Numbers include floats and integers:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_int = 25 %}
|
||||
{% assign my_float = -39.756 %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Boolean
|
||||
|
||||
Booleans are either `true` or `false`. No quotations are necessary when declaring a boolean:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign foo = true %}
|
||||
{% assign bar = false %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Nil
|
||||
|
||||
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/#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:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if user %}
|
||||
Hello {{ user.name }}!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Tags or outputs that return `nil` will not print anything to the page.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
The current user is {{ user.name }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
The current user is
|
||||
```
|
||||
|
||||
## Array
|
||||
|
||||
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/" | prepend: site.baseurl }}).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||
{% for user in site.users %}
|
||||
{{ user }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Tobi Laura Tetsuro Adam
|
||||
```
|
||||
|
||||
### Accessing specific items in arrays
|
||||
|
||||
You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero. A negative index will count from the end of the array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||
{{ site.users[0] }}
|
||||
{{ site.users[1] }}
|
||||
{{ site.users[-1] }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Tobi
|
||||
Laura
|
||||
Adam
|
||||
```
|
||||
|
||||
### Initializing arrays
|
||||
|
||||
You cannot initialize arrays using only Liquid.
|
||||
|
||||
You can, however, use the [`split`]({{ "/filters/split/" | prepend: site.baseurl }}) filter to break a string into an array of substrings.
|
||||
|
||||
## EmptyDrop
|
||||
|
||||
An EmptyDrop object is returned if you try to access a deleted object. 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 %}
|
||||
```
|
||||
|
||||
### Checking for emptiness
|
||||
|
||||
You can check to see if an object exists or not before you access any of its attributes.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% unless pages == empty %}
|
||||
<h1>{{ pages.frontpage.title }}</h1>
|
||||
<div>{{ pages.frontpage.content }}</div>
|
||||
{% endunless %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Both empty strings and empty arrays will return `true` if checked for equivalence with `empty`.
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: Variations of Liquid
|
||||
description: An overview of the different installations of Liquid and how Liquid can change depending on where you're using it.
|
||||
---
|
||||
|
||||
Liquid is a flexible, safe language, and is used in many different environments. Liquid was created for use in [Shopify](https://www.shopify.com) stores, and is also used extensively on [Jekyll](https://jekyllrb.com) websites. Over time, both Shopify and Jekyll have added their own objects, tags, and filters to Liquid. The most popular versions of Liquid that exist are **Liquid**, **Shopify Liquid for themes**, and **Jekyll Liquid**.
|
||||
|
||||
This site documents the latest version of **Liquid** including betas and release candidates — that is, Liquid as it exists outside of Shopify and Jekyll. If you download the Liquid repository or install it as a [gem](https://rubygems.org/gems/liquid), you will get access to whatever objects, tags, and filters are in the version of Liquid that you chose.
|
||||
|
||||
## Shopify
|
||||
|
||||
Shopify always uses the latest version of Liquid as a base, but Shopify adds a significant number of objects, tags, and filters to Liquid for use in merchants' stores. These include objects representing store, product, and customer information, and filters for displaying store data and manipulating storefront assets like product images.
|
||||
|
||||
Shopify has several versions of Liquid. The most popular version is used to build Shopify themes. To learn about the Liquid elements that you can use to build Shopify themes, and to learn about the other versions of Liquid at Shopify, refer to the [Shopify Liquid reference](https://shopify.dev/api/liquid).
|
||||
|
||||
## Jekyll
|
||||
|
||||
[Jekyll](https://jekyllrb.com) is a static site generator, a command-line tool that creates websites by merging templates with content files. Jekyll uses Liquid as its template language, and adds a few objects, tags, and filters. These include objects representing content pages, tags for including snippets of content in others, and filters for manipulating strings and URLs.
|
||||
|
||||
Jekyll also powers [GitHub Pages](https://pages.github.com/), a web hosting service that lets you push a Jekyll installation to a GitHub repository and have the resulting website published. This website is built using GitHub Pages.
|
||||
|
||||
Jekyll might not be using the latest version of Liquid. This means that the tags and filters listed on this site may not work in Jekyll. Often the Jekyll project will wait for a stable release of Liquid rather than using a beta or release candidate version. To see which version of Liquid is being used by Jekyll or GitHub Pages, check the **runtime dependencies** section of the gem page for [Jekyll](https://rubygems.org/gems/jekyll) or [GitHub Pages](https://rubygems.org/gems/github-pages).
|
||||
|
||||
Jekyll's version of Liquid is documented in the [Liquid section of Jekyll's documentation](https://jekyllrb.com/docs/liquid/). If you want to try out Jekyll's version of Liquid, you can clone the Jekyll project or install Jekyll as a gem and test Liquid on a static site.
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
title: Whitespace control
|
||||
description: An overview of controlling whitespace between code in the Liquid template language.
|
||||
---
|
||||
|
||||
In Liquid, you can include a hyphen in your tag syntax `{% raw %}{{-{% endraw %}`, `{% raw %}-}}{% endraw %}`, `{% raw %}{%-{% endraw %}`, and `{% raw %}-%}{% endraw %}` to strip whitespace from the left or right side of a rendered tag.
|
||||
|
||||
Normally, even if it doesn't print text, any line of Liquid in your template will still print a blank line in your rendered HTML:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_variable = "tomato" %}
|
||||
{{ my_variable }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Notice the blank line before "tomato" in the rendered template:
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_variable = "tomato" %}
|
||||
{{ my_variable }}
|
||||
```
|
||||
|
||||
By including a hyphen in your `assign` closing delimiter, you can strip the whitespace following it from the rendered template:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_variable = "tomato" -%}
|
||||
{{ my_variable }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_variable = "tomato" -%}
|
||||
{{ my_variable }}
|
||||
```
|
||||
|
||||
If you don't want any of your tags to print whitespace, as a general rule you can add hyphens to both sides of all your tags (`{% raw %}{%-{% endraw %}` and `{% raw %}-%}{% endraw %}`):
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign username = "John G. Chalmers-Smith" %}
|
||||
{% if username and username.size > 10 %}
|
||||
Wow, {{ username }} , you have a long name!
|
||||
{% else %}
|
||||
Hello there!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output without whitespace control</p>
|
||||
```text
|
||||
{% assign username = "John G. Chalmers-Smith" %}
|
||||
{% if username and username.size > 10 %}
|
||||
Wow, {{ username }} , you have a long name!
|
||||
{% else %}
|
||||
Hello there!
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign username = "John G. Chalmers-Smith" -%}
|
||||
{%- if username and username.size > 10 -%}
|
||||
Wow, {{ username -}} , you have a long name!
|
||||
{%- else -%}
|
||||
Hello there!
|
||||
{%- endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output with whitespace control</p>
|
||||
```text
|
||||
{% assign username = "John G. Chalmers-Smith" -%}
|
||||
{%- if username and username.size > 10 -%}
|
||||
Wow, {{ username -}} , you have a long name!
|
||||
{%- else -%}
|
||||
Hello there!
|
||||
{%- endif %}
|
||||
```
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
title: Liquid template language
|
||||
description: Liquid is a template language and accompanying rendering engine. It is built for security, so is perfect for rendering custom templates from your users.
|
||||
|
||||
# Build settings
|
||||
baseurl: /liquid # the subpath of your site, e.g. /blog/
|
||||
url: https://shopify.github.io # the base hostname & protocol for your site
|
||||
permalink: pretty
|
||||
exclude:
|
||||
- README.md
|
||||
- CNAME
|
||||
- Gemfile
|
||||
- Gemfile.lock
|
||||
- Gruntfile.js
|
||||
- package.json
|
||||
- package-lock.json
|
||||
- node_modules
|
||||
- vendor
|
||||
- tags
|
||||
keep_files: ["css"]
|
||||
|
||||
# Collections
|
||||
collections:
|
||||
basics:
|
||||
output: true
|
||||
tags:
|
||||
output: true
|
||||
filters:
|
||||
output: true
|
||||
|
||||
# Plugins
|
||||
plugins:
|
||||
- jekyll-redirect-from
|
||||
|
||||
# Front matter defaults
|
||||
defaults:
|
||||
- scope:
|
||||
path: "" # an empty string here means all files in the project
|
||||
values:
|
||||
layout: default
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: abs
|
||||
description: Liquid filter that returns the absolute value of a number.
|
||||
redirect_from: /filters/
|
||||
---
|
||||
|
||||
Returns the absolute value of a number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ -17 | abs }}
|
||||
{{ 4 | abs }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ -17 | abs }}
|
||||
{{ 4 | abs }}
|
||||
```
|
||||
|
||||
`abs` will also work on a string that only contains a number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "-19.86" | abs }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "-19.86" | abs }}
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: append
|
||||
description: Liquid filter that appends a string to another string.
|
||||
---
|
||||
|
||||
Adds the specified string to the end of another string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
```
|
||||
|
||||
`append` can also accept a variable as its argument.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign filename = "/index.html" %}
|
||||
{{ "website.com" | append: filename }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign filename = "/index.html" %}
|
||||
{{ "website.com" | append: filename }}
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: at_least
|
||||
description: Liquid filter that limits a number to a minimum value.
|
||||
version-badge: 4.0.1
|
||||
---
|
||||
|
||||
Limits a number to a minimum value.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 4 | at_least: 5 }}
|
||||
{{ 4 | at_least: 3 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
5
|
||||
4
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: at_most
|
||||
description: Liquid filter that limits a number to a maximum value.
|
||||
version-badge: 4.0.1
|
||||
---
|
||||
|
||||
Limits a number to a maximum value.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 4 | at_most: 5 }}
|
||||
{{ 4 | at_most: 3 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
4
|
||||
3
|
||||
```
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: capitalize
|
||||
description: Liquid filter that capitalizes the first character of a string and downcases the remaining characters.
|
||||
---
|
||||
|
||||
Makes the first character of a string capitalized and converts the remaining characters to lowercase.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "title" | capitalize }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "title" | capitalize }}
|
||||
```
|
||||
|
||||
Only the first character of a string is capitalized, so later words are not capitalized:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "my GREAT title" | capitalize }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "my GREAT title" | capitalize }}
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: ceil
|
||||
description: Liquid filter that returns the ceiling of a number by rounding up to the nearest integer.
|
||||
---
|
||||
|
||||
Rounds an input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 1.2 | ceil }}
|
||||
{{ 2.0 | ceil }}
|
||||
{{ 183.357 | ceil }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 1.2 | ceil }}
|
||||
{{ 2.0 | ceil }}
|
||||
{{ 183.357 | ceil }}
|
||||
```
|
||||
|
||||
Here the input value is a string:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "3.5" | ceil }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "3.5" | ceil }}
|
||||
```
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: compact
|
||||
description: Liquid filter that removes nil values from an array.
|
||||
version-badge: 4.0.0
|
||||
---
|
||||
|
||||
Removes any `nil` values from an array.
|
||||
|
||||
For this example, assume `site.pages` is an array of content pages for a website, and some of these pages have an attribute called `category` that specifies their content category. If we `map` those categories to an array, some of the array items might be `nil` if any pages do not have a `category` attribute.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign site_categories = site.pages | map: "category" %}
|
||||
|
||||
{% for category in site_categories %}
|
||||
- {{ category }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
- business
|
||||
- celebrities
|
||||
-
|
||||
- lifestyle
|
||||
- sports
|
||||
-
|
||||
- technology
|
||||
```
|
||||
|
||||
By using `compact` when we create our `site_categories` array, we can remove all the `nil` values in the array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign site_categories = site.pages | map: "category" | compact %}
|
||||
|
||||
{% for category in site_categories %}
|
||||
- {{ category }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
- business
|
||||
- celebrities
|
||||
- lifestyle
|
||||
- sports
|
||||
- technology
|
||||
```
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: concat
|
||||
description: Liquid filter that concatenates arrays.
|
||||
version-badge: 4.0.0
|
||||
---
|
||||
|
||||
Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign fruits = "apples, oranges, peaches" | split: ", " %}
|
||||
{% assign vegetables = "carrots, turnips, potatoes" | split: ", " %}
|
||||
|
||||
{% assign everything = fruits | concat: vegetables %}
|
||||
|
||||
{% for item in everything %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
- apples
|
||||
- oranges
|
||||
- peaches
|
||||
- carrots
|
||||
- turnips
|
||||
- potatoes
|
||||
```
|
||||
|
||||
You can string together multiple `concat` filters to join more than two arrays.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign furniture = "chairs, tables, shelves" | split: ", " %}
|
||||
|
||||
{% assign everything = fruits | concat: vegetables | concat: furniture %}
|
||||
|
||||
{% for item in everything %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
- apples
|
||||
- oranges
|
||||
- peaches
|
||||
- carrots
|
||||
- turnips
|
||||
- potatoes
|
||||
- chairs
|
||||
- tables
|
||||
- shelves
|
||||
```
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: date
|
||||
description: Liquid filter that prints and formats dates.
|
||||
---
|
||||
|
||||
Converts a timestamp into another date format. The format for this syntax is the same as [`strftime`](http://strftime.net). The input uses the same format as Ruby's [`Time.parse`](https://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html#method-c-parse).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ article.published_at | date: "%a, %b %d, %y" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Fri, Jul 17, 15
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ article.published_at | date: "%Y" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
2015
|
||||
```
|
||||
|
||||
`date` works on strings if they contain well-formatted dates.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "March 14, 2016" | date: "%b %d, %y" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "March 14, 2016" | date: "%b %d, %y" }}
|
||||
```
|
||||
|
||||
To get the current time, pass the special word `"now"` (or `"today"`) to `date`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}.
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}.
|
||||
```
|
||||
|
||||
Note that the value will be the current time of when the page was last generated from the template, not when the page is presented to a user if caching or static site generation is involved.
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: default
|
||||
description: Liquid filter that specifies a fallback in case a value doesn't exist.
|
||||
---
|
||||
|
||||
Sets a default value for any variable with no assigned value. `default` will show its value if the input is `nil`, `false`, or empty.
|
||||
|
||||
In this example, `product_price` is not defined, so the default value is used.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ product_price | default: 2.99 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ product_price | default: 2.99 }}
|
||||
```
|
||||
|
||||
In this example, `product_price` is defined, so the default value is not used.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign product_price = 4.99 %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign product_price = 4.99 %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
```
|
||||
|
||||
In this example, `product_price` is empty, so the default value is used.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign product_price = "" %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign product_price = "" %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
```
|
||||
|
||||
### Allowing `false` {%- include version-badge.html version="5.0.0" %}
|
||||
|
||||
To allow variables to return `false` instead of the default value, you can use the `allow_false` parameter.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign display_price = false %}
|
||||
{{ display_price | default: true, allow_false: true }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
|
||||
false
|
||||
```
|
||||
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: divided_by
|
||||
description: Liquid filter that divides a number by another number.
|
||||
---
|
||||
|
||||
Divides a number by another number.
|
||||
|
||||
The result is rounded down to the nearest integer (that is, the [floor]({{ "/filters/floor/" | prepend: site.baseurl }})) if the divisor is an integer.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 16 | divided_by: 4 }}
|
||||
{{ 5 | divided_by: 3 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 16 | divided_by: 4 }}
|
||||
{{ 5 | divided_by: 3 }}
|
||||
```
|
||||
|
||||
### Controlling rounding
|
||||
|
||||
`divided_by` produces a result of the same type as the divisor — that is, if you divide by an integer, the result will be an integer. If you divide by a float (a number with a decimal in it), the result will be a float.
|
||||
|
||||
For example, here the divisor is an integer:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 20 | divided_by: 7 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 20 | divided_by: 7 }}
|
||||
```
|
||||
|
||||
Here it is a float:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 20 | divided_by: 7.0 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 20 | divided_by: 7.0 }}
|
||||
```
|
||||
|
||||
### Changing variable types
|
||||
|
||||
You might want to use a variable as a divisor, in which case you can't simply add `.0` to convert it to a float. In these cases, you can `assign` a version of your variable converted to a float using the `times` filter.
|
||||
|
||||
In this example, we're dividing by a variable that contains an integer, so we get an integer:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_integer = 7 %}
|
||||
{{ 20 | divided_by: my_integer }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_integer = 7 %}
|
||||
{{ 20 | divided_by: my_integer }}
|
||||
```
|
||||
|
||||
Here, we [multiply]({{ "/filters/times/" | prepend: site.baseurl }}) the variable by `1.0` to get a float, then divide by the float instead:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_integer = 7 %}
|
||||
{% assign my_float = my_integer | times: 1.0 %}
|
||||
{{ 20 | divided_by: my_float }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_integer = 7 %}
|
||||
{% assign my_float = my_integer | times: 1.0 %}
|
||||
{{ 20 | divided_by: my_float }}
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: downcase
|
||||
description: Liquid filter that converts a string to lowercase.
|
||||
---
|
||||
|
||||
Makes each character in a string lowercase. It has no effect on strings which are already all lowercase.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Parker Moore" | downcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Parker Moore" | downcase }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "apple" | downcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "apple" | downcase }}
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: escape
|
||||
description: Liquid filter that escapes URL-unsafe characters in a string.
|
||||
---
|
||||
|
||||
Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn't change strings that don't have anything to escape.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Have you read 'James & the Giant Peach'?" | escape }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Have you read 'James & the Giant Peach'?" | escape }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Tetsuro Takara" | escape }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Tetsuro Takara" | escape }}
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: escape_once
|
||||
description: Liquid filter that escapes URL-unsafe characters in a string once.
|
||||
---
|
||||
|
||||
Escapes a string without changing existing escaped entities. It doesn't change strings that don't have anything to escape.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: first
|
||||
description: Liquid filter that returns the first item of an array.
|
||||
---
|
||||
|
||||
Returns the first item of an array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | split: " " | first }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | split: " " | first }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.first }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.first }}
|
||||
```
|
||||
|
||||
You can use `first` with dot notation when you need to use the filter inside a tag:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if my_array.first == "zebra" %}
|
||||
Here comes a zebra!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: floor
|
||||
description: Liquid filter that returns the floor of a number by rounding down to the nearest integer.
|
||||
---
|
||||
|
||||
Rounds an input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 1.2 | floor }}
|
||||
{{ 2.0 | floor }}
|
||||
{{ 183.357 | floor }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 1.2 | floor }}
|
||||
{{ 2.0 | floor }}
|
||||
{{ 183.357 | floor }}
|
||||
```
|
||||
|
||||
Here the input value is a string:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "3.5" | floor }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "3.5" | floor }}
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: join
|
||||
description: Liquid filter that joins an array of strings into a single string.
|
||||
---
|
||||
|
||||
Combines the items in an array into a single string using the argument as a separator.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{{ beatles | join: " and " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{{ beatles | join: " and " }}
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: last
|
||||
description: Liquid filter that returns the last item of an array.
|
||||
---
|
||||
|
||||
Returns the last item of an array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | split: " " | last }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | split: " " | last }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.last }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.last }}
|
||||
```
|
||||
|
||||
You can use `last` with dot notation when you need to use the filter inside a tag:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if my_array.last == "tiger" %}
|
||||
There goes a tiger!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: lstrip
|
||||
description: Liquid filter that removes all whitespace from the left side of a string.
|
||||
---
|
||||
|
||||
Removes all whitespace (tabs, spaces, and newlines) from the **left** side of a string. It does not affect spaces between words.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ " So much room for activities " | lstrip }}!
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ " So much room for activities " | lstrip }}!
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: map
|
||||
description: Liquid filter that creates an array of values by extracting a named property from an object.
|
||||
---
|
||||
|
||||
Creates an array of values by extracting the values of a named property from another object.
|
||||
|
||||
In this example, assume the object `site.pages` contains all the metadata for a website. Using `assign` with the `map` filter creates a variable that contains only the values of the `category` properties of everything in the `site.pages` object.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign all_categories = site.pages | map: "category" %}
|
||||
|
||||
{% for item in all_categories %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
- business
|
||||
- celebrities
|
||||
- lifestyle
|
||||
- sports
|
||||
- technology
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: minus
|
||||
description: Liquid filter that subtracts one number from another number.
|
||||
---
|
||||
|
||||
Subtracts a number from another number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 4 | minus: 2 }}
|
||||
{{ 16 | minus: 4 }}
|
||||
{{ 183.357 | minus: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 4 | minus: 2 }}
|
||||
{{ 16 | minus: 4 }}
|
||||
{{ 183.357 | minus: 12 }}
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: modulo
|
||||
description: Liquid filter that returns the remainder of a division operation.
|
||||
---
|
||||
|
||||
Returns the remainder of a division operation.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 3 | modulo: 2 }}
|
||||
{{ 24 | modulo: 7 }}
|
||||
{{ 183.357 | modulo: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 3 | modulo: 2 }}
|
||||
{{ 24 | modulo: 7 }}
|
||||
{{ 183.357 | modulo: 12 }}
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: newline_to_br
|
||||
description: Liquid filter that converts newlines in a string to HTML <br /> tags.
|
||||
---
|
||||
|
||||
Inserts an HTML line break (`<br />`) in front of each newline (`\n`) in a string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | newline_to_br }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```html
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | newline_to_br }}
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: plus
|
||||
description: Liquid filter that adds one number to another number.
|
||||
---
|
||||
|
||||
Adds a number to another number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 4 | plus: 2 }}
|
||||
{{ 16 | plus: 4 }}
|
||||
{{ 183.357 | plus: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 4 | plus: 2 }}
|
||||
{{ 16 | plus: 4 }}
|
||||
{{ 183.357 | plus: 12 }}
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: prepend
|
||||
description: Liquid filter that prepends a string to the beginning of another string.
|
||||
---
|
||||
|
||||
Adds the specified string to the beginning of another string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
|
||||
```
|
||||
|
||||
`prepend` can also accept a variable as its argument.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign url = "example.com" %}
|
||||
{{ "/index.html" | prepend: url }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign url = "example.com" %}
|
||||
{{ "/index.html" | prepend: url }}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: remove
|
||||
description: Liquid filter that removes all occurences of a given substring from a string.
|
||||
---
|
||||
|
||||
Removes every occurrence of the specified substring from a string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "I strained to see the train through the rain" | remove: "rain" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "I strained to see the train through the rain" | remove: "rain" }}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: remove_first
|
||||
description: Liquid filter that removes the first occurence of a given substring from a string.
|
||||
---
|
||||
|
||||
Removes only the first occurrence of the specified substring from a string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "I strained to see the train through the rain" | remove_first: "rain" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "I strained to see the train through the rain" | remove_first: "rain" }}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: replace
|
||||
description: Liquid filter that replaces all occurences of a given substring in a string.
|
||||
---
|
||||
|
||||
Replaces every occurrence of the first argument in a string with the second argument.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: replace_first
|
||||
description: Liquid filter that replaces the first occurrence of a given substring in a string.
|
||||
---
|
||||
|
||||
Replaces only the first occurrence of the first argument in a string with the second argument.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }}
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: reverse
|
||||
description: Liquid filter that reverses an array, or a string converted to an array.
|
||||
---
|
||||
|
||||
Reverses the order of the items in an array. `reverse` cannot reverse a string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array | reverse | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array | reverse | join: ", " }}
|
||||
```
|
||||
|
||||
Although `reverse` cannot be used directly on a string, you can split a string into an array, reverse the array, and rejoin it by chaining together filters.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: round
|
||||
description: Liquid filter that rounds a number to the nearest integer.
|
||||
---
|
||||
|
||||
Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 1.2 | round }}
|
||||
{{ 2.7 | round }}
|
||||
{{ 183.357 | round: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 1.2 | round }}
|
||||
{{ 2.7 | round }}
|
||||
{{ 183.357 | round: 2 }}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: rstrip
|
||||
description: Liquid filter that removes all whitespace from the right side of a string.
|
||||
---
|
||||
|
||||
Removes all whitespace (tabs, spaces, and newlines) from the **right** side of a string. It does not affect spaces between words.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ " So much room for activities " | rstrip }}!
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ " So much room for activities " | rstrip }}!
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: size
|
||||
description: Liquid filter that returns the number of characters in a string or the number of items in an array.
|
||||
---
|
||||
|
||||
Returns the number of characters in a string or the number of items in an array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | size }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | size }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array.size }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array.size }}
|
||||
```
|
||||
|
||||
You can use `size` with dot notation when you need to use the filter inside a tag:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if site.pages.size > 10 %}
|
||||
This is a big website!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: slice
|
||||
description: Liquid filter that returns a substring or item from a given position in a string or array.
|
||||
---
|
||||
|
||||
Returns a substring of one character or series of array items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of array items to be returned.
|
||||
|
||||
String or array indices are numbered starting from 0.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Liquid" | slice: 0 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Liquid" | slice: 0 }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Liquid" | slice: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Liquid" | slice: 2 }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Liquid" | slice: 2, 5 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Liquid" | slice: 2, 5 }}
|
||||
```
|
||||
|
||||
Here the input value is an array:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
{{ beatles | slice: 1, 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
{{ beatles | slice: 1, 2 }}
|
||||
```
|
||||
|
||||
If the first argument is a negative number, the indices are counted from the end of the string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Liquid" | slice: -3, 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Liquid" | slice: -3, 2 }}
|
||||
```
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: sort
|
||||
description: Liquid filter that sorts an array in case-sensitive order.
|
||||
---
|
||||
|
||||
Sorts items in an array in case-sensitive order.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
|
||||
|
||||
{{ my_array | sort | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
|
||||
|
||||
{{ my_array | sort | join: ", " }}
|
||||
```
|
||||
|
||||
An optional argument specifies which property of the array's items to use for sorting.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign products_by_price = collection.products | sort: "price" %}
|
||||
{% for product in products_by_price %}
|
||||
<h4>{{ product.title }}</h4>
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: sort_natural
|
||||
description: Liquid filter that sorts an array in case-insensitive order.
|
||||
version-badge: 4.0.0
|
||||
---
|
||||
|
||||
Sorts items in an array in case-insensitive order.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
|
||||
|
||||
{{ my_array | sort_natural | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
|
||||
|
||||
{{ my_array | sort_natural | join: ", " }}
|
||||
```
|
||||
|
||||
An optional argument specifies which property of the array's items to use for sorting.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign products_by_company = collection.products | sort_natural: "company" %}
|
||||
{% for product in products_by_company %}
|
||||
<h4>{{ product.title }}</h4>
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: split
|
||||
description: Liquid filter that splits a string into an array using separators.
|
||||
---
|
||||
|
||||
Divides a string into an array using the argument as a separator. `split` is commonly used to convert comma-separated items from a string to an array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{% for member in beatles %}
|
||||
{{ member }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{% for member in beatles %}
|
||||
{{ member }}
|
||||
{% endfor %}
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: strip
|
||||
description: Liquid filter that removes all whitespace from the left and right sides of a string.
|
||||
---
|
||||
|
||||
Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between words.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ " So much room for activities " | strip }}!
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ " So much room for activities " | strip }}!
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: strip_html
|
||||
description: Liquid filter that removes HTML tags from a string.
|
||||
---
|
||||
|
||||
Removes any HTML tags from a string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: strip_newlines
|
||||
description: Liquid filter that removes newline characters from a string.
|
||||
---
|
||||
|
||||
Removes any newline characters (line breaks) from a string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | strip_newlines }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```html
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | strip_newlines }}
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: times
|
||||
description: Liquid filter that multiplies a number by another number.
|
||||
---
|
||||
|
||||
Multiplies a number by another number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ 3 | times: 2 }}
|
||||
{{ 24 | times: 7 }}
|
||||
{{ 183.357 | times: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ 3 | times: 2 }}
|
||||
{{ 24 | times: 7 }}
|
||||
{{ 183.357 | times: 12 }}
|
||||
```
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: truncate
|
||||
description: Liquid filter that truncates a string to a given number of characters.
|
||||
---
|
||||
|
||||
Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (...) is appended to the string and is included in the character count.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | truncate: 20 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncate: 20 }}
|
||||
```
|
||||
|
||||
### Custom ellipsis
|
||||
|
||||
`truncate` takes an optional second argument that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.
|
||||
|
||||
The length of the second argument counts against the number of characters specified by the first argument. For example, if you want to truncate a string to exactly 10 characters, and use a 3-character ellipsis, use **13** for the first argument of `truncate`, since the ellipsis counts as 3 characters.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | truncate: 25, ", and so on" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncate: 25, ", and so on" }}
|
||||
```
|
||||
|
||||
### No ellipsis
|
||||
|
||||
You can truncate to the exact number of characters specified by the first argument and avoid showing trailing characters by passing a blank string as the second argument.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | truncate: 20, "" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncate: 20, "" }}
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: truncatewords
|
||||
description: Liquid filter that truncates a string to a given number of words.
|
||||
---
|
||||
|
||||
Shortens a string down to the number of words passed as an argument. If the specified number of words is less than the number of words in the string, an ellipsis (...) is appended to the string.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3 }}
|
||||
```
|
||||
|
||||
### Custom ellipsis
|
||||
|
||||
`truncatewords` takes an optional second argument that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3, "--" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3, "--" }}
|
||||
```
|
||||
|
||||
### No ellipsis
|
||||
|
||||
You can avoid showing trailing characters by passing a blank string as the second argument.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3, "" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3, "" }}
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: uniq
|
||||
description: Liquid filter that removes duplicate items from an array.
|
||||
---
|
||||
|
||||
Removes any duplicate items in an array.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}
|
||||
|
||||
{{ my_array | uniq | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}
|
||||
|
||||
{{ my_array | uniq | join: ", " }}
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: upcase
|
||||
description: Liquid filter that converts a string to uppercase.
|
||||
---
|
||||
|
||||
Makes each character in a string uppercase. It has no effect on strings which are already all uppercase.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Parker Moore" | upcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Parker Moore" | upcase }}
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "APPLE" | upcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "APPLE" | upcase }}
|
||||
```
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: url_decode
|
||||
description: Liquid filter that decodes percent-encoded characters in a string.
|
||||
version-badge: 4.0.0
|
||||
---
|
||||
|
||||
Decodes a string that has been encoded as a URL or by [`url_encode`]({{ "/filters/url_encode/" | prepend: site.baseurl }}).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "%27Stop%21%27+said+Fred" | url_decode }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "%27Stop%21%27+said+Fred" | url_decode }}
|
||||
```
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: url_encode
|
||||
description: Liquid filter that encodes URL-unsafe characters in a string.
|
||||
---
|
||||
|
||||
Converts any URL-unsafe characters in a string into percent-encoded characters.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "john@liquid.com" | url_encode }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "john@liquid.com" | url_encode }}
|
||||
```
|
||||
|
||||
Note that `url_encode` will turn a space into a `+` sign instead of a percent-encoded character.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{{ "Tetsuro Takara" | url_encode }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{{ "Tetsuro Takara" | url_encode }}
|
||||
```
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
title: where
|
||||
description: Liquid filter that selects from arrays.
|
||||
version-badge: 4.0.2
|
||||
---
|
||||
|
||||
Creates an array including only the objects with a given property value, or any [truthy]({{ "/basics/truthy-and-falsy/#truthy" | prepend: site.baseurl }}) value by default.
|
||||
|
||||
In this example, assume you have a list of products and you want to show your kitchen products separately. Using `where`, you can create an array containing only the products that have a `"type"` of `"kitchen"`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
All products:
|
||||
{% for product in products %}
|
||||
- {{ product.title }}
|
||||
{% endfor %}
|
||||
|
||||
{% assign kitchen_products = products | where: "type", "kitchen" %}
|
||||
|
||||
Kitchen products:
|
||||
{% for product in kitchen_products %}
|
||||
- {{ product.title }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
All products:
|
||||
- Vacuum
|
||||
- Spatula
|
||||
- Television
|
||||
- Garlic press
|
||||
|
||||
Kitchen products:
|
||||
- Spatula
|
||||
- Garlic press
|
||||
```
|
||||
|
||||
Say instead you have a list of products and you only want to show those that are available to buy. You can `where` with a property name but no target value to include all products with a [truthy]({{ "/basics/truthy-and-falsy/#truthy" | prepend: site.baseurl }}) `"available"` value.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
All products:
|
||||
{% for product in products %}
|
||||
- {{ product.title }}
|
||||
{% endfor %}
|
||||
|
||||
{% assign available_products = products | where: "available" %}
|
||||
|
||||
Available products:
|
||||
{% for product in available_products %}
|
||||
- {{ product.title }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
All products:
|
||||
- Coffee mug
|
||||
- Limited edition sneakers
|
||||
- Boring sneakers
|
||||
|
||||
Available products:
|
||||
- Coffee mug
|
||||
- Boring sneakers
|
||||
```
|
||||
|
||||
The `where` filter can also be used to find a single object in an array when combined with the `first` filter. For example, say you want to show off the shirt in your new fall collection.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign new_shirt = products | where: "type", "shirt" | first %}
|
||||
|
||||
Featured product: {{ new_shirt.title }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Featured product: Hawaiian print sweater vest
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="home-banner">
|
||||
<h1>Liquid</h1>
|
||||
<p>Safe, customer-facing template language for flexible web apps.</p>
|
||||
<p class="btn-row">
|
||||
<a href="https://github.com/Shopify/liquid/archive/master.zip" target="_blank" class="btn">
|
||||
<span aria-hidden="true">{% include icons/desktop-download.svg %}</span> Download
|
||||
</a>
|
||||
<a href="https://github.com/Shopify/liquid" target="_blank" class="btn">
|
||||
<span aria-hidden="true">{% include icons/mark-github.svg %}</span> View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,24 @@
|
||||
<div class="home-users-grid">
|
||||
<div class="home-users-grid__item">
|
||||
<a href="https://jekyllrb.com" target="_blank">
|
||||
<img src="{{ '/images/jekyll-logo.png' | relative_url }}" alt="Jekyll logo" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="home-users-grid__item">
|
||||
<a href="https://www.desk.com" target="_blank">
|
||||
<img src="{{ '/images/salesforcedesk-logo.png' | relative_url }}" alt="Desk logo" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="home-users-grid__item">
|
||||
<a href="//www.zendesk.com" target="_blank">
|
||||
<img src="{{ '/images/zendesk-logo.png' | relative_url }}" alt="ZenDesk logo" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="home-users-grid__item">
|
||||
<a href="//500px.com" target="_blank">
|
||||
<img src="{{ '/images/500px-logo.png' | relative_url }}" alt="500px logo" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="home-users-blurb">...and <a href="https://github.com/Shopify/liquid/wiki#who-uses-liquid" target="_blank">many more</a></p>
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4 6h3v-6h2v6h3l-4 4zm11-4h-4v1h4v8h-14v-8h4v-1h-4c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2h5.34c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1z" fill-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 304 B |
Executable
+1
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 0c-4.42 0-8 3.58-8 8 0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38l-.01-1.49c-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38 3.16-1.06 5.45-4.06 5.45-7.59 0-4.42-3.58-8-8-8z" fill-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 682 B |
Executable
+1
@@ -0,0 +1 @@
|
||||
<svg height="16" viewBox="0 0 12 16" width="12" xmlns="http://www.w3.org/2000/svg"><path d="m11.41 9h-10.82c-.59 0-.59-.41-.59-1s0-1 .59-1h10.81c.59 0 .59.41.59 1s0 1-.59 1zm0-4h-10.82c-.59 0-.59-.41-.59-1s0-1 .59-1h10.81c.59 0 .59.41.59 1s0 1-.59 1zm-10.82 6h10.81c.59 0 .59.41.59 1s0 1-.59 1h-10.81c-.59 0-.59-.41-.59-1s0-1 .59-1z"/></svg>
|
||||
|
After Width: | Height: | Size: 341 B |
@@ -0,0 +1,33 @@
|
||||
<div class="sidebar">
|
||||
<header class="sidebar__logo" role="banner">
|
||||
{% if page.home %}
|
||||
Liquid
|
||||
{% else %}
|
||||
<a href="{{ "/" | relative_url }}">Liquid</a>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
{%- assign sections = "basics, tags, filters" | split: ", " -%}
|
||||
|
||||
<nav class="sidebar__nav">
|
||||
<div class="sidebar__nav-interior">
|
||||
{%- for section in sections -%}
|
||||
<h3 class="section__header" id="{{ section }}-section">{{ section | capitalize }}</h3>
|
||||
|
||||
<ul class="section__links">
|
||||
{%- for item in site[section] -%}
|
||||
<li class="section__item">
|
||||
<a href="{{ item.url | relative_url }}" class="section__link{% if item.url == page.url %} section__link--is-active{% endif %}">{{ item.title }}</a>
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
|
||||
{%- if sections contains page.collection -%}
|
||||
<script type="text/javascript">
|
||||
document.getElementById("{{ page.collection }}").scrollIntoView();
|
||||
</script>
|
||||
{%- endif -%}
|
||||
</nav>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<span class="version-badge" title="This feature is available since version {{ include.version }}" data-version="{{ include.version }}"></span>
|
||||
@@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<title>{% if page.title %}{{ page.title }} – {% endif %}{{ site.title }}</title>
|
||||
|
||||
<meta name="description" content="{{ page.description | default: site.description }}">
|
||||
<meta name="author" content="Shopify">
|
||||
|
||||
<meta name="robots" content="index, follow">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||
|
||||
<link rel="stylesheet" href="{{ '/css/main.css' | relative_url }}">
|
||||
<link rel="icon" type="image/png" href="{{ '/images/icons/water-drop-32x.png' | relative_url }}" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="{{ '/images/icons/water-drop-64x.png' | relative_url }}" sizes="64x64">
|
||||
<link rel="canonical" href="{{ page.url | replace: 'index.html','' | absolute_url }}">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | relative_url }}" />
|
||||
|
||||
<meta property="og:site_name" content="{{ site.title }}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="{{ page.url | relative_url }}">
|
||||
<meta property="og:title" content="{{ page.title | default: site.title }}">
|
||||
<meta property="og:description" content="{{ page.description | default: site.description }}">
|
||||
|
||||
<meta name="twitter:site" content="{{ site.title }}">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:url" content="{{ site.url | relative_url }}">
|
||||
<meta name="twitter:title" content="{{ page.title | default: site.title }}">
|
||||
<meta name="twitter:description" content="{{ page.description | default: site.description }}">
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-49178120-52"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-49178120-52');
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
{% include sidebar.html %}
|
||||
|
||||
<div class="content__overlay"></div>
|
||||
<main class="content__area" role="main">
|
||||
<div class="content">
|
||||
<button class="menu-button">
|
||||
<span aria-hidden="true">{% include icons/three-bars.svg %}</span>
|
||||
<span>Menu</span>
|
||||
</button>
|
||||
{% if page.title -%}
|
||||
<h1>{{ page.title }}
|
||||
{%- if page.version-badge -%}
|
||||
{%- include version-badge.html version=page.version-badge -%}
|
||||
{%- endif -%}</h1>
|
||||
{%- endif %}
|
||||
{{ content }}
|
||||
</div>
|
||||
</main>
|
||||
<script src="{{ '/js/script.js' | relative_url }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,184 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset some basic elements
|
||||
*/
|
||||
body, h1, h2, h3, h4, h5, h6,
|
||||
p, blockquote, pre, hr,
|
||||
dl, dd, ol, ul, figure {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic styling
|
||||
*/
|
||||
body {
|
||||
font-family: $base-font-family;
|
||||
font-size: $base-font-size;
|
||||
line-height: $base-line-height;
|
||||
font-weight: 300;
|
||||
color: $color-slate;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
/** Set `margin-bottom` to maintain vertical rhythm */
|
||||
|
||||
h1, h2, h3, h4, h5, h6,
|
||||
p, blockquote, pre,
|
||||
ul, ol, dl, figure,
|
||||
%vertical-rhythm {
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
/** Images */
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/** Figures */
|
||||
|
||||
figure > img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
font-size: $small-font-size;
|
||||
}
|
||||
|
||||
/** Lists */
|
||||
ul, ol {
|
||||
margin-left: $spacing-unit;
|
||||
}
|
||||
|
||||
li {
|
||||
> ul, > ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Links */
|
||||
a {
|
||||
color: $color-blue-5;
|
||||
|
||||
&:visited {
|
||||
color: #609;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
/** Headings */
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
font-weight: 300;
|
||||
margin-top: $spacing-unit;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: $spacing-unit;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
color: lighten($color-slate, 30%);
|
||||
border-left: 2px solid lighten($color-slate, 50%);
|
||||
padding-left: $spacing-unit / 2;
|
||||
letter-spacing: -1px;
|
||||
font-style: italic;
|
||||
|
||||
> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: Menlo, Monaco, monospace;
|
||||
font-size: 15px;
|
||||
border-radius: 3px;
|
||||
background-color: lighten($color-blue-1, 0.9);
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid $color-blue-2;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
|
||||
> code {
|
||||
border: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
display: block;
|
||||
height: 1px;
|
||||
border: 0;
|
||||
background-color: lighten($color-slate, 50%);
|
||||
margin-bottom: $spacing-unit/2;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
display: block;
|
||||
margin: 15px 0;
|
||||
border-collapse: collapse;
|
||||
thead {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 6px 13px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
tbody {
|
||||
vertical-align: middle;
|
||||
border-color: inherit;
|
||||
}
|
||||
tr {
|
||||
border-top: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
vertical-align: inherit;
|
||||
}
|
||||
td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
/* Don't use a margin on code samples within tables */
|
||||
pre {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.8;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
.btn {
|
||||
color: $color-white;
|
||||
fill: currentColor;
|
||||
display: flex;
|
||||
background: $color-blue-5;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: $spacing-unit/4 $spacing-unit/2;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
background: $color-blue-4;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
@include phone-and-up {
|
||||
justify-content: center;
|
||||
|
||||
&:first-child {
|
||||
justify-content: flex-start;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
svg {
|
||||
margin-right: $spacing-unit / 4;
|
||||
width: $base-font-size * 1.5;
|
||||
height: $base-font-size * 1.5;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn:visited {
|
||||
color: $color-white;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
margin-bottom: 0;
|
||||
|
||||
@include phone-and-up {
|
||||
flex-direction: row;
|
||||
|
||||
.btn:not(:first-child) {
|
||||
margin-left: $spacing-unit / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*============================================================================
|
||||
Menu button
|
||||
==============================================================================*/
|
||||
.menu-button {
|
||||
display: inline-block;
|
||||
font-size: $small-font-size;
|
||||
background: none;
|
||||
border: none;
|
||||
margin: $spacing-unit / 2 0 $spacing-unit / 2 ($spacing-unit / 4 * -1);
|
||||
padding: $spacing-unit / 4;
|
||||
color: $color-slate;
|
||||
|
||||
@include tablet-and-up {
|
||||
display: none;
|
||||
}
|
||||
|
||||
svg {
|
||||
margin-right: $spacing-unit / 4;
|
||||
width: $base-font-size;
|
||||
height: $base-font-size;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
.content__item {
|
||||
margin-bottom: $spacing-unit * 2;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
background: lighten($color-blue-1, 1);
|
||||
}
|
||||
|
||||
.code-label {
|
||||
padding: 4px 12px;
|
||||
margin-bottom: 0;
|
||||
font-size: 15px;
|
||||
background: darken($color-blue-1, 5);
|
||||
border: 1px solid $color-blue-2;
|
||||
border-bottom: none;
|
||||
border-radius: 3px 3px 0 0;
|
||||
}
|
||||
|
||||
.code-label + .highlighter-rouge .highlight {
|
||||
border-top: none;
|
||||
border-radius: 0 0 3px 3px;
|
||||
}
|
||||
|
||||
.version-badge {
|
||||
padding: 4px;
|
||||
margin-left: 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 300;
|
||||
background: lighten($color-blue-1, 1);
|
||||
border: 1px solid $color-blue-2;
|
||||
border-radius: 3px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.version-badge:before {
|
||||
content: attr(data-version);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
.home-banner {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid lighten($color-slate, 50%);
|
||||
padding-bottom: $spacing-unit;
|
||||
margin-bottom: $spacing-unit;
|
||||
|
||||
h1 {
|
||||
font-size: 4em;
|
||||
|
||||
// &:after {
|
||||
// content: '\01F4A7'; // Water droplet emoji
|
||||
// vertical-align: middle;
|
||||
// }
|
||||
|
||||
@include phone-and-up {
|
||||
font-size: 5em;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
color: lighten($color-slate, 20%);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
.home-users-grid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
.home-users-grid__item{
|
||||
flex: 1;
|
||||
margin-right: $spacing-unit / 2;
|
||||
max-width: 50%;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.home-users-blurb {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
$sidebar-width: 250px;
|
||||
$logo-height: 130px;
|
||||
$wrapper-width: 800px;
|
||||
|
||||
body {
|
||||
// display: flex;
|
||||
// flex-direction: column;
|
||||
|
||||
// @include tablet-and-up {
|
||||
// flex-direction: row;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/*============================================================================
|
||||
Content Area
|
||||
==============================================================================*/
|
||||
|
||||
.content__area {
|
||||
width: 100%;
|
||||
|
||||
@include tablet-and-up {
|
||||
padding: $spacing-unit $spacing-unit $spacing-unit ($spacing-unit + $sidebar-width);
|
||||
}
|
||||
}
|
||||
|
||||
.content__overlay {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.content__overlay--is-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.content {
|
||||
max-width: $wrapper-width;
|
||||
margin: 0 auto;
|
||||
padding: 0 $spacing-unit;
|
||||
@extend %clearfix;
|
||||
}
|
||||
|
||||
/*============================================================================
|
||||
Sidebar
|
||||
==============================================================================*/
|
||||
|
||||
.sidebar {
|
||||
background: $color-blue-5;
|
||||
width: $sidebar-width;
|
||||
position: fixed;
|
||||
transform: translateX($sidebar-width * -1);
|
||||
transition: all 0.15s ease;
|
||||
z-index: 2;
|
||||
height: 100vh;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
|
||||
@include tablet-and-up {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar--is-visible {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.sidebar__logo {
|
||||
border-bottom: 1px solid $color-blue-4;
|
||||
color: $color-white;
|
||||
font-size: $base-font-size * 2;
|
||||
font-weight: 300;
|
||||
height: $logo-height;
|
||||
line-height: $logo-height;
|
||||
margin-bottom: 0;
|
||||
text-align: center;
|
||||
|
||||
|
||||
// &:after {
|
||||
// content: '\01F4A7'; // Water droplet emoji
|
||||
// vertical-align: middle;
|
||||
// }
|
||||
|
||||
a {
|
||||
color: $color-white;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar__nav {
|
||||
|
||||
font-weight: bold;
|
||||
max-height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sidebar__nav-interior {
|
||||
height: 100%;
|
||||
// Add a bit more padding at the bottom for consistency.
|
||||
padding: $spacing-unit $spacing-unit ($spacing-unit + $logo-height);
|
||||
}
|
||||
|
||||
.section__header {
|
||||
font-size: 1em;
|
||||
text-decoration: none;
|
||||
color: $color-white;
|
||||
margin-top: 0;
|
||||
margin-bottom: $spacing-unit / 4;
|
||||
|
||||
.section__links + & {
|
||||
margin-top: $spacing-unit;
|
||||
}
|
||||
}
|
||||
|
||||
.section__links {
|
||||
font-size: 0.9em;
|
||||
font-weight: normal;
|
||||
|
||||
list-style: none;
|
||||
margin-left: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
.section__item {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.section__link {
|
||||
display: inline-block;
|
||||
margin-top: $spacing-unit/4;
|
||||
opacity: 0.75;
|
||||
text-decoration: none;
|
||||
color: $color-white;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:empty {
|
||||
// there is an error in the liquid logic that spits out a
|
||||
// empty last-child
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:visited {
|
||||
color: $color-white;
|
||||
}
|
||||
}
|
||||
|
||||
.section__link--is-active {
|
||||
font-weight: bold;
|
||||
opacity: 1;
|
||||
color: $color-white;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// I got the blues, man.
|
||||
// 1 --> 5, lightest --> darkest.
|
||||
|
||||
$color-blue-1: #E8F8FF;
|
||||
$color-blue-2: #B4DCED;
|
||||
$color-blue-3: #91C9E8;
|
||||
$color-blue-4: #67B8DE;
|
||||
$color-blue-5: #3399CC;
|
||||
$color-white: #ffffff;
|
||||
$color-slate: #5E5E5E;
|
||||
@@ -0,0 +1,5 @@
|
||||
$base-font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
|
||||
$base-font-size: 18px;
|
||||
$small-font-size: $base-font-size * 0.875;
|
||||
$base-line-height: 1.5;
|
||||
$spacing-unit: 40px;
|
||||
@@ -0,0 +1,16 @@
|
||||
%clearfix {
|
||||
&:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
position:absolute;
|
||||
left:-10000px;
|
||||
top:auto;
|
||||
width:1px;
|
||||
height:1px;
|
||||
overflow:hidden;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*============================================================================
|
||||
Media queries
|
||||
==============================================================================*/
|
||||
|
||||
$phone-width: 375px;
|
||||
$tablet-width: 768px;
|
||||
$desktop-width: 1024px;
|
||||
|
||||
@mixin phone {
|
||||
@media (max-width: #{$phone-width}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin phone-and-up {
|
||||
@media (min-width: #{$phone-width}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin phone-to-tablet {
|
||||
@media (min-width: #{$phone-width}) and (max-width: #{$tablet-width - 1px}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin tablet {
|
||||
@media (min-width: #{$tablet-width}) and (max-width: #{$desktop-width - 1px}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin tablet-and-up {
|
||||
@media (min-width: #{$tablet-width}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin desktop {
|
||||
@media (min-width: #{$desktop-width}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Syntax highlighting styles
|
||||
*/
|
||||
.highlight {
|
||||
// background: #fff;
|
||||
@extend %vertical-rhythm;
|
||||
|
||||
.c { color: #998; font-style: italic } // Comment
|
||||
.err { color: #a61717; background-color: #e3d2d2 } // Error
|
||||
.k { font-weight: bold } // Keyword
|
||||
.o { font-weight: bold } // Operator
|
||||
.cm { color: #998; font-style: italic } // Comment.Multiline
|
||||
.cp { color: #999; font-weight: bold } // Comment.Preproc
|
||||
.c1 { color: #998; font-style: italic } // Comment.Single
|
||||
.cs { color: #999; font-weight: bold; font-style: italic } // Comment.Special
|
||||
.gd { color: #000; background-color: #fdd } // Generic.Deleted
|
||||
.gd .x { color: #000; background-color: #faa } // Generic.Deleted.Specific
|
||||
.ge { font-style: italic } // Generic.Emph
|
||||
.gr { color: #a00 } // Generic.Error
|
||||
.gh { color: #999 } // Generic.Heading
|
||||
.gi { color: #000; background-color: #dfd } // Generic.Inserted
|
||||
.gi .x { color: #000; background-color: #afa } // Generic.Inserted.Specific
|
||||
.go { color: #888 } // Generic.Output
|
||||
.gp { color: #555 } // Generic.Prompt
|
||||
.gs { font-weight: bold } // Generic.Strong
|
||||
.gu { color: #aaa } // Generic.Subheading
|
||||
.gt { color: #a00 } // Generic.Traceback
|
||||
.kc { font-weight: bold } // Keyword.Constant
|
||||
.kd { font-weight: bold } // Keyword.Declaration
|
||||
.kp { font-weight: bold } // Keyword.Pseudo
|
||||
.kr { font-weight: bold } // Keyword.Reserved
|
||||
.kt { color: #458; font-weight: bold } // Keyword.Type
|
||||
.m { color: #099 } // Literal.Number
|
||||
.s { color: #d14 } // Literal.String
|
||||
.na { color: #008080 } // Name.Attribute
|
||||
.nb { color: #0086B3 } // Name.Builtin
|
||||
.nc { color: #458; font-weight: bold } // Name.Class
|
||||
.no { color: #008080 } // Name.Constant
|
||||
.ni { color: #800080 } // Name.Entity
|
||||
.ne { color: #900; font-weight: bold } // Name.Exception
|
||||
.nf { color: #900; font-weight: bold } // Name.Function
|
||||
.nn { color: #555 } // Name.Namespace
|
||||
.nt { color: #000080 } // Name.Tag
|
||||
.nv { color: #008080 } // Name.Variable
|
||||
.ow { font-weight: bold } // Operator.Word
|
||||
.w { color: #bbb } // Text.Whitespace
|
||||
.mf { color: #099 } // Literal.Number.Float
|
||||
.mh { color: #099 } // Literal.Number.Hex
|
||||
.mi { color: #099 } // Literal.Number.Integer
|
||||
.mo { color: #099 } // Literal.Number.Oct
|
||||
.sb { color: #d14 } // Literal.String.Backtick
|
||||
.sc { color: #d14 } // Literal.String.Char
|
||||
.sd { color: #d14 } // Literal.String.Doc
|
||||
.s2 { color: #d14 } // Literal.String.Double
|
||||
.se { color: #d14 } // Literal.String.Escape
|
||||
.sh { color: #d14 } // Literal.String.Heredoc
|
||||
.si { color: #d14 } // Literal.String.Interpol
|
||||
.sx { color: #d14 } // Literal.String.Other
|
||||
.sr { color: #009926 } // Literal.String.Regex
|
||||
.s1 { color: #d14 } // Literal.String.Single
|
||||
.ss { color: #990073 } // Literal.String.Symbol
|
||||
.bp { color: #999 } // Name.Builtin.Pseudo
|
||||
.vc { color: #008080 } // Name.Variable.Class
|
||||
.vg { color: #008080 } // Name.Variable.Global
|
||||
.vi { color: #008080 } // Name.Variable.Instance
|
||||
.il { color: #099 } // Literal.Number.Integer.Long
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
---
|
||||
title: Control flow
|
||||
description: An overview of control flow and conditional tags in the Liquid template language.
|
||||
redirect_from: /tags/
|
||||
---
|
||||
|
||||
Control flow tags create conditions that decide whether blocks of Liquid code get executed.
|
||||
|
||||
## if
|
||||
|
||||
Executes a block of code only if a certain condition is `true`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if product.title == "Awesome Shoes" %}
|
||||
These shoes are awesome!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
These shoes are awesome!
|
||||
```
|
||||
|
||||
## unless
|
||||
|
||||
The opposite of `if` – executes a block of code only if a certain condition is **not** met.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% unless product.title == "Awesome Shoes" %}
|
||||
These shoes are not awesome.
|
||||
{% endunless %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
These shoes are not awesome.
|
||||
```
|
||||
|
||||
This would be the equivalent of doing the following:
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% if product.title != "Awesome Shoes" %}
|
||||
These shoes are not awesome.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## elsif / else
|
||||
|
||||
Adds more conditions within an `if` or `unless` block.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- If customer.name = "anonymous" -->
|
||||
{% if customer.name == "kevin" %}
|
||||
Hey Kevin!
|
||||
{% elsif customer.name == "anonymous" %}
|
||||
Hey Anonymous!
|
||||
{% else %}
|
||||
Hi Stranger!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Hey Anonymous!
|
||||
```
|
||||
|
||||
## case/when
|
||||
|
||||
Creates a switch statement to execute a particular block of code when a variable has a specified value. `case` initializes the switch statement, and `when` statements define the various conditions.
|
||||
|
||||
A `when` tag can accept multiple values. When multiple values are provided, the expression is returned when the variable matches any of the values inside of the tag. Provide the values as a comma-separated list, or separate them using an `or` operator.
|
||||
|
||||
An optional `else` statement at the end of the case provides code to execute if none of the conditions are met.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign handle = "cake" %}
|
||||
{% case handle %}
|
||||
{% when "cake" %}
|
||||
This is a cake
|
||||
{% when "cookie", "biscuit" %}
|
||||
This is a cookie
|
||||
{% else %}
|
||||
This is not a cake nor a cookie
|
||||
{% endcase %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
This is a cake
|
||||
```
|
||||
@@ -0,0 +1,465 @@
|
||||
---
|
||||
title: Iteration
|
||||
description: An overview of iteration or "loop" tags in the Liquid template language.
|
||||
---
|
||||
|
||||
Iteration tags repeatedly run blocks of code.
|
||||
|
||||
## for
|
||||
|
||||
Repeatedly executes a block of code. For a full list of attributes available within a `for` loop, refer to the [`forloop` object](#forloop-object).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% for product in collection.products %}
|
||||
{{ product.title }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
hat shirt pants
|
||||
```
|
||||
|
||||
### else
|
||||
|
||||
Specifies a fallback case for a `for` loop which will run if the loop has zero length.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% for product in collection.products %}
|
||||
{{ product.title }}
|
||||
{% else %}
|
||||
The collection is empty.
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
The collection is empty.
|
||||
```
|
||||
|
||||
### break
|
||||
|
||||
Causes the loop to stop iterating when it encounters the `break` tag.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% for i in (1..5) %}
|
||||
{% if i == 4 %}
|
||||
{% break %}
|
||||
{% else %}
|
||||
{{ i }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
1 2 3
|
||||
```
|
||||
|
||||
### continue
|
||||
|
||||
Causes the loop to skip the current iteration when it encounters the `continue` tag.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% for i in (1..5) %}
|
||||
{% if i == 4 %}
|
||||
{% continue %}
|
||||
{% else %}
|
||||
{{ i }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
1 2 3 5
|
||||
```
|
||||
|
||||
## for (parameters)
|
||||
|
||||
### limit
|
||||
|
||||
Limits the loop to the specified number of iterations.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- if array = [1,2,3,4,5,6] -->
|
||||
{% for item in array limit:2 %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
1 2
|
||||
```
|
||||
|
||||
### offset
|
||||
|
||||
Begins the loop at the specified index.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- if array = [1,2,3,4,5,6] -->
|
||||
{% for item in array offset:2 %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
3 4 5 6
|
||||
```
|
||||
|
||||
To start a loop from where the last loop using the same iterator left off, pass the special word `continue`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- if array = [1,2,3,4,5,6] -->
|
||||
{% for item in array limit: 3 %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% for item in array limit: 3 offset: continue %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
1 2 3
|
||||
4 5 6
|
||||
```
|
||||
|
||||
### range
|
||||
|
||||
Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers, and can be pulled from a variable.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% for i in (3..5) %}
|
||||
{{ i }}
|
||||
{% endfor %}
|
||||
|
||||
{% assign num = 4 %}
|
||||
{% assign range = (1..num) %}
|
||||
{% for i in range %}
|
||||
{{ i }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
3 4 5
|
||||
1 2 3 4
|
||||
```
|
||||
|
||||
### reversed
|
||||
|
||||
Reverses the order of the loop. Note that this flag's spelling is different from the filter `reverse`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!-- if array = [1,2,3,4,5,6] -->
|
||||
{% for item in array reversed %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
6 5 4 3 2 1
|
||||
```
|
||||
|
||||
## forloop (object)
|
||||
|
||||
Information about a parent [`for` loop](#for).
|
||||
|
||||
```json
|
||||
{
|
||||
"first": true,
|
||||
"index": 1,
|
||||
"index0": 0,
|
||||
"last": false,
|
||||
"length": 4,
|
||||
"rindex": 3
|
||||
}
|
||||
```
|
||||
|
||||
### Use the `forloop` object
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign smoothie_flavors = "orange, strawberry, banana" | split: ", " %}
|
||||
|
||||
{% for flavor in smoothie_flavors -%}
|
||||
{%- if forloop.length > 0 -%}
|
||||
{{ flavor }}{% unless forloop.last %}-{% endunless -%}
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
orange-strawberry-banana
|
||||
```
|
||||
|
||||
### forloop (properties)
|
||||
|
||||
| Property | Description | Returns |
|
||||
| --- | --- | --- |
|
||||
| `length` | The total number of iterations in the loop. | `number` |
|
||||
| `parentloop` | The parent `forloop` object. If the current `for` loop isn't nested inside another `for` loop, then `nil` is returned. | `forloop` |
|
||||
| `index` | The 1-based index of the current iteration. | `number` |
|
||||
| `index0` | The 0-based index of the current iteration. | `number` |
|
||||
| `rindex` | The 1-based index of the current iteration, in reverse order. | `number` |
|
||||
| `rindex0` | The 0-based index of the current iteration, in reverse order. | `number` |
|
||||
| `first` | Returns `true` if the current iteration is the first. Returns `false` if not. | `boolean` |
|
||||
| `last` | Returns `true` if the current iteration is the last. Returns `false` if not. | `boolean` |
|
||||
|
||||
## cycle
|
||||
|
||||
Loops through a group of strings and prints them in the order that they were passed as arguments. Each time `cycle` is called, the next string argument is printed.
|
||||
|
||||
`cycle` must be used within a [for](#for) loop block.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% cycle "one", "two", "three" %}
|
||||
{% cycle "one", "two", "three" %}
|
||||
```
|
||||
|
||||
Uses for `cycle` include:
|
||||
|
||||
- applying odd/even classes to rows in a table
|
||||
- applying a unique class to the last product thumbnail in a row
|
||||
|
||||
## cycle (parameters)
|
||||
|
||||
`cycle` accepts a "cycle group" parameter in cases where you need multiple `cycle` blocks in one template. If no name is supplied for the cycle group, then it is assumed that multiple calls with the same parameters are one group.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% cycle "first": "one", "two", "three" %}
|
||||
{% cycle "second": "one", "two", "three" %}
|
||||
{% cycle "second": "one", "two", "three" %}
|
||||
{% cycle "first": "one", "two", "three" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% cycle "first": "one", "two", "three" %}
|
||||
{% cycle "second": "one", "two", "three" %}
|
||||
{% cycle "second": "one", "two", "three" %}
|
||||
{% cycle "first": "one", "two", "three" %}
|
||||
```
|
||||
|
||||
## tablerow
|
||||
|
||||
Generates an HTML table. Must be wrapped in opening `<table>` and closing `</table>` HTML tags. For a full list of attributes available within a `tablerow` loop, refer to the [`tablerowloop` object](#tablerowloop-object).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<table>
|
||||
{% tablerow product in collection.products %}
|
||||
{{ product.title }}
|
||||
{% endtablerow %}
|
||||
</table>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```html
|
||||
<table>
|
||||
<tr class="row1">
|
||||
<td class="col1">
|
||||
Cool Shirt
|
||||
</td>
|
||||
<td class="col2">
|
||||
Alien Poster
|
||||
</td>
|
||||
<td class="col3">
|
||||
Batman Poster
|
||||
</td>
|
||||
<td class="col4">
|
||||
Bullseye Shirt
|
||||
</td>
|
||||
<td class="col5">
|
||||
Another Classic Vinyl
|
||||
</td>
|
||||
<td class="col6">
|
||||
Awesome Jeans
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
```
|
||||
|
||||
## tablerow (parameters)
|
||||
|
||||
### cols
|
||||
|
||||
Defines how many columns the tables should have.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% tablerow product in collection.products cols:2 %}
|
||||
{{ product.title }}
|
||||
{% endtablerow %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```html
|
||||
<table>
|
||||
<tr class="row1">
|
||||
<td class="col1">
|
||||
Cool Shirt
|
||||
</td>
|
||||
<td class="col2">
|
||||
Alien Poster
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="row2">
|
||||
<td class="col1">
|
||||
Batman Poster
|
||||
</td>
|
||||
<td class="col2">
|
||||
Bullseye Shirt
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="row3">
|
||||
<td class="col1">
|
||||
Another Classic Vinyl
|
||||
</td>
|
||||
<td class="col2">
|
||||
Awesome Jeans
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
```
|
||||
|
||||
#### limit
|
||||
|
||||
Exits the `tablerow` loop after a specific index.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% tablerow product in collection.products cols:2 limit:3 %}
|
||||
{{ product.title }}
|
||||
{% endtablerow %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### offset
|
||||
|
||||
Starts the `tablerow` loop after a specific index.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% tablerow product in collection.products cols:2 offset:3 %}
|
||||
{{ product.title }}
|
||||
{% endtablerow %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### range
|
||||
|
||||
Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
<!--variable number example-->
|
||||
|
||||
{% assign num = 4 %}
|
||||
<table>
|
||||
{% tablerow i in (1..num) %}
|
||||
{{ i }}
|
||||
{% endtablerow %}
|
||||
</table>
|
||||
|
||||
<!--literal number example-->
|
||||
|
||||
<table>
|
||||
{% tablerow i in (3..5) %}
|
||||
{{ i }}
|
||||
{% endtablerow %}
|
||||
</table>
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## tablerowloop (object)
|
||||
|
||||
Information about a parent [`tablerow` loop](#tablerow).
|
||||
|
||||
```json
|
||||
{
|
||||
"col": 1,
|
||||
"col0": 0,
|
||||
"col_first": true,
|
||||
"col_last": false,
|
||||
"first": true,
|
||||
"index": 1,
|
||||
"index0": 0,
|
||||
"last": false,
|
||||
"length": 5,
|
||||
"rindex": 5,
|
||||
"rindex0": 4,
|
||||
"row": 1
|
||||
}
|
||||
```
|
||||
|
||||
### tablerowloop (properties)
|
||||
|
||||
| Property | Description | Returns |
|
||||
| --- | --- | --- |
|
||||
| `col` | The 1-based index of the current column. | `number` |
|
||||
| `col0` | The 0-based index of the current column. | `number` |
|
||||
| `col_first` | Returns `true` if the current column is the first in the row. Returns `false` if not. | `boolean` |
|
||||
| `col_last` | Returns `true` if the current column is the last in the row. Returns `false` if not. | `boolean` |
|
||||
| `first` | Returns `true` if the current iteration is the first. Returns `false` if not. | `boolean` |
|
||||
| `index` | The 1-based index of the current iteration. | `number` |
|
||||
| `index0` | The 0-based index of the current iteration. | `number` |
|
||||
| `last` | Returns `true` if the current iteration is the last. Returns `false` if not. | `boolean` |
|
||||
| `length` | The total number of iterations in the loop. | `number` |
|
||||
| `rindex` | The 1-based index of the current iteration, in reverse order. | `number` |
|
||||
| `rindex0` | The 0-based index of the current iteration, in reverse order. | `number` |
|
||||
| `row` | The 1-based index of current row. | `number` |
|
||||
@@ -0,0 +1,220 @@
|
||||
---
|
||||
title: Template
|
||||
description: An overview of template tags in the Liquid template language.
|
||||
redirect_from:
|
||||
- /tags/comment/
|
||||
- /tags/raw/
|
||||
---
|
||||
|
||||
Template tags tell Liquid where to disable processing for comments or non-Liquid markup, and how to establish relations among template files.
|
||||
|
||||
## comment
|
||||
|
||||
Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing `comment` blocks will not be printed, and any Liquid code within will not be executed.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign verb = "turned" %}
|
||||
{% comment %}
|
||||
{% assign verb = "converted" %}
|
||||
{% endcomment %}
|
||||
Anything you put between {% comment %} and {% endcomment %} tags
|
||||
is {{ verb }} into a comment.
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```liquid
|
||||
{% assign verb = "turned" %}
|
||||
{% comment %}
|
||||
{% assign verb = "converted" %}
|
||||
{% endcomment %}
|
||||
Anything you put between {% comment %} and {% endcomment %} tags
|
||||
is {{ verb }} into a comment.
|
||||
```
|
||||
|
||||
## Inline comments {%- include version-badge.html version="5.4.0" %}
|
||||
|
||||
You can use inline comments to prevent an expression from being rendered or output. Any text inside of the tag also won't be rendered or output.
|
||||
|
||||
You can create multi-line inline comments. However, each line must begin with a `#`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% # for i in (1..3) -%}
|
||||
{{ i }}
|
||||
{% # endfor %}
|
||||
|
||||
{%
|
||||
###############################
|
||||
# This is a comment
|
||||
# across multiple lines
|
||||
###############################
|
||||
%}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
|
||||
|
||||
```
|
||||
|
||||
### Inline comments inside `liquid` tags
|
||||
|
||||
You can use the inline comment tag inside [`liquid` tags](#liquid). The tag must be used for each line that you want to comment.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% liquid
|
||||
# this is a comment
|
||||
assign topic = 'Learning about comments!'
|
||||
echo topic
|
||||
%}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Learning about comments!
|
||||
```
|
||||
|
||||
## raw
|
||||
|
||||
Temporarily disables tag processing. This is useful for generating certain content that uses conflicting syntax, such as [Mustache](https://mustache.github.io/) or [Handlebars](https://handlebarsjs.com/).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{{ "%7B%25+raw+%25%7D" | url_decode }}{% raw %}
|
||||
In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not.
|
||||
{% endraw %}{{ "%7B%25+endraw+%25%7D" | url_decode }}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% raw %}
|
||||
In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not.
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## liquid {%- include version-badge.html version="5.0.0" %}
|
||||
|
||||
Encloses multiple tags within one set of delimiters, to allow writing Liquid logic more concisely.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% liquid
|
||||
case section.blocks.size
|
||||
when 1
|
||||
assign column_size = ''
|
||||
when 2
|
||||
assign column_size = 'one-half'
|
||||
when 3
|
||||
assign column_size = 'one-third'
|
||||
else
|
||||
assign column_size = 'one-quarter'
|
||||
endcase %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Because any tag blocks opened within a `liquid` tag must also be closed within the same tag, use [`echo`](#echo) to output data.
|
||||
|
||||
## echo {%- include version-badge.html version="5.0.0" %}
|
||||
|
||||
Outputs an expression in the rendered HTML. This is identical to wrapping an expression in `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`, but works inside [`liquid`](#liquid) tags and supports [filters]({{ "/basics/introduction/#filters" | prepend: site.baseurl }}).
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% liquid
|
||||
for product in collection.products
|
||||
echo product.title | capitalize
|
||||
endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
Hat Shirt Pants
|
||||
```
|
||||
|
||||
## render {%- include version-badge.html version="5.0.0" %}
|
||||
|
||||
Insert the rendered content of another template within the current template.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% render "template-name" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Note that you don't need to write the file's `.liquid` extension.
|
||||
|
||||
The code within the rendered template does **not** automatically have access to the variables assigned using [variable tags]({{ "/tags/variable/" | prepend: site.baseurl }}) within the parent template. Similarly, variables assigned within the rendered template cannot be accessed by code in any other template.
|
||||
|
||||
## render (parameters)
|
||||
|
||||
Variables assigned using [variable tags]({{ "/tags/variable/" | prepend: site.baseurl }}) can be passed to a template by listing them as parameters on the `render` tag.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_variable = "apples" %}
|
||||
{% render "name", my_variable: my_variable, my_other_variable: "oranges" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
One or more objects can be passed to a template.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign featured_product = all_products["product_handle"] %}
|
||||
{% render "product", product: featured_product %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### with
|
||||
|
||||
A single object can be passed to a template by using the `with` and optional `as` parameters.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign featured_product = all_products["product_handle"] %}
|
||||
{% render "product" with featured_product as product %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
In the example above, the `product` variable in the rendered template will hold the value of `featured_product` from the parent template.
|
||||
|
||||
### for
|
||||
|
||||
A template can be rendered once for each value of an enumerable object by using the `for` and optional `as` parameters.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign variants = product.variants %}
|
||||
{% render "product_variant" for variants as variant %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
In the example above, the template will be rendered once for each variant of the product, and the `variant` variable will hold a different product variant object for each iteration.
|
||||
|
||||
When using the `for` parameter, the [`forloop`]({{ "/tags/iteration/#forloop-object" | prepend: site.baseurl }}) object is accessible within the rendered template.
|
||||
|
||||
## include
|
||||
|
||||
_The `include` tag is deprecated; please use [`render`](#render) instead._
|
||||
|
||||
Insert the rendered content of another template within the current template.
|
||||
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% include "template-name" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
The `include` tag works similarly to the [`render`](#render) tag, but it allows the code inside of the rendered template to access and overwrite the variables within its parent template. It has been deprecated because the way that it handles variables reduces performance and makes Liquid code harder to both read and maintain.
|
||||
|
||||
Note that when a template is rendered using the [`render`](#render) tag, the `include` tag cannot be used within the template.
|
||||
@@ -0,0 +1,145 @@
|
||||
---
|
||||
title: Variable
|
||||
description: An overview of tags for creating variables in the Liquid template language.
|
||||
---
|
||||
|
||||
Variable tags create new Liquid variables.
|
||||
|
||||
## assign
|
||||
|
||||
Creates a new named variable.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign my_variable = false %}
|
||||
{% if my_variable != true %}
|
||||
This statement is valid.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
This statement is valid.
|
||||
```
|
||||
|
||||
Wrap a value in quotations `"` to save it as a string variable.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign foo = "bar" %}
|
||||
{{ foo }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign foo = "bar" %}
|
||||
{{ foo }}
|
||||
```
|
||||
|
||||
## capture
|
||||
|
||||
Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created using `capture` are stored as strings.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% capture my_variable %}I am being captured.{% endcapture %}
|
||||
{{ my_variable }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
I am being captured.
|
||||
```
|
||||
|
||||
Using `capture`, you can create complex strings using other variables created with `assign`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign favorite_food = "pizza" %}
|
||||
{% assign age = 35 %}
|
||||
|
||||
{% capture about_me %}
|
||||
I am {{ age }} and my favorite food is {{ favorite_food }}.
|
||||
{% endcapture %}
|
||||
|
||||
{{ about_me }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
I am 35 and my favourite food is pizza.
|
||||
```
|
||||
|
||||
## increment
|
||||
|
||||
Creates and outputs a new number variable with initial value `0`. On subsequent calls, it increases its value by one and outputs the new value.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% increment my_counter %}
|
||||
{% increment my_counter %}
|
||||
{% increment my_counter %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% increment my_counter %}
|
||||
{% increment my_counter %}
|
||||
{% increment my_counter %}
|
||||
```
|
||||
|
||||
Variables created using `increment` are independent from variables created using `assign` or `capture`.
|
||||
|
||||
In the example below, a variable named "var" is created using `assign`. The `increment` tag is then used several times on a variable with the same name. Note that the `increment` tag does not affect the value of "var" that was created using `assign`.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% assign var = 10 %}
|
||||
{% increment var %}
|
||||
{% increment var %}
|
||||
{% increment var %}
|
||||
{{ var }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% assign var = 10 %}
|
||||
{% increment var %}
|
||||
{% increment var %}
|
||||
{% increment var %}
|
||||
{{ var }}
|
||||
```
|
||||
|
||||
## decrement
|
||||
|
||||
Creates and outputs a new number variable with initial value `-1`. On subsequent calls, it decreases its value by one and outputs the new value.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{%- raw -%}
|
||||
{% decrement variable %}
|
||||
{% decrement variable %}
|
||||
{% decrement variable %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% decrement variable %}
|
||||
{% decrement variable %}
|
||||
{% decrement variable %}
|
||||
```
|
||||
|
||||
Like [increment](#increment), variables declared using `decrement` are independent from variables created using `assign` or `capture`.
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
---
|
||||
layout: null
|
||||
---
|
||||
|
||||
@charset "utf-8";
|
||||
|
||||
@import "partials/defaults";
|
||||
@import "partials/colors";
|
||||
@import "partials/helpers";
|
||||
@import "partials/media-queries";
|
||||
|
||||
@import "modules/base";
|
||||
@import "modules/layout";
|
||||
@import "modules/buttons";
|
||||
@import "modules/home-banner";
|
||||
@import "modules/home-users-grid";
|
||||
@import "modules/content-area";
|
||||
|
||||
@import "vendors/syntax-highlighting";
|
||||
@@ -1,50 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ProductsFilter
|
||||
def price(integer)
|
||||
format("$%.2d USD", integer / 100.0)
|
||||
end
|
||||
|
||||
def prettyprint(text)
|
||||
text.gsub(/\*(.*)\*/, '<b>\1</b>')
|
||||
end
|
||||
|
||||
def count(array)
|
||||
array.size
|
||||
end
|
||||
|
||||
def paragraph(p)
|
||||
"<p>#{p}</p>"
|
||||
end
|
||||
end
|
||||
|
||||
class Servlet < LiquidServlet
|
||||
def index
|
||||
{ 'date' => Time.now }
|
||||
end
|
||||
|
||||
def products
|
||||
{ 'products' => products_list, 'more_products' => more_products_list, 'description' => description, 'section' => 'Snowboards', 'cool_products' => true }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def products_list
|
||||
[
|
||||
{ 'name' => 'Arbor Draft', 'price' => 39900, 'description' => 'the *arbor draft* is a excellent product' },
|
||||
{ 'name' => 'Arbor Element', 'price' => 40000, 'description' => 'the *arbor element* rocks for freestyling' },
|
||||
{ 'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity' }
|
||||
]
|
||||
end
|
||||
|
||||
def more_products_list
|
||||
[
|
||||
{ 'name' => 'Arbor Catalyst', 'price' => 39900, 'description' => 'the *arbor catalyst* is an advanced drop-through for freestyle and flatground performance and versatility' },
|
||||
{ 'name' => 'Arbor Fish', 'price' => 40000, 'description' => 'the *arbor fish* is a compact pin that features an extended wheelbase and time-honored teardrop shape' }
|
||||
]
|
||||
end
|
||||
|
||||
def description
|
||||
"List of Products ~ This is a list of products with price and description."
|
||||
end
|
||||
end
|
||||
@@ -1,30 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
||||
def do_GET(req, res)
|
||||
handle(:get, req, res)
|
||||
end
|
||||
|
||||
def do_POST(req, res)
|
||||
handle(:post, req, res)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def handle(_type, req, res)
|
||||
@request = req
|
||||
@response = res
|
||||
|
||||
@request.path_info =~ /(\w+)\z/
|
||||
@action = Regexp.last_match(1) || 'index'
|
||||
@assigns = send(@action) if respond_to?(@action)
|
||||
|
||||
@response['Content-Type'] = "text/html"
|
||||
@response.status = 200
|
||||
@response.body = Liquid::Template.parse(read_template).render(@assigns, filters: [ProductsFilter])
|
||||
end
|
||||
|
||||
def read_template(filename = @action)
|
||||
File.read("#{__dir__}/templates/#{filename}.liquid")
|
||||
end
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'webrick'
|
||||
require 'rexml/document'
|
||||
|
||||
require_relative '../../lib/liquid'
|
||||
require_relative 'liquid_servlet'
|
||||
require_relative 'example_servlet'
|
||||
|
||||
# Setup webrick
|
||||
server = WEBrick::HTTPServer.new(Port: ARGV[1] || 3000)
|
||||
server.mount('/', Servlet)
|
||||
trap("INT") { server.shutdown }
|
||||
server.start
|
||||
@@ -1,6 +0,0 @@
|
||||
<p>Hello world!</p>
|
||||
|
||||
<p>It is {{date}}</p>
|
||||
|
||||
|
||||
<p>Check out the <a href="/products">Products</a> screen </p>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
|
||||
<title>products</title>
|
||||
|
||||
<meta name="ROBOTS" content="ALL" />
|
||||
<meta http-equiv="imagetoolbar" content="no" />
|
||||
<meta name="MSSmartTagsPreventParsing" content="true" />
|
||||
<meta name="Copyright" content="(c) 2005 Copyright content: Copyright design: Tobias Luetke" />
|
||||
<!-- (c) Copyright 2005 by Tobias Luetke All Rights Reserved. -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% assign all_products = products | concat: more_products %}
|
||||
<h1>{{ description | split: '~' | first }}</h1>
|
||||
|
||||
<h2>{{ description | split: '~' | last }}</h2>
|
||||
|
||||
<h2>There are currently {{all_products | count}} products in the {{section}} catalog</h2>
|
||||
|
||||
{% if cool_products %}
|
||||
Cool products :)
|
||||
{% else %}
|
||||
Uncool products :(
|
||||
{% endif %}
|
||||
|
||||
<ul id="products">
|
||||
|
||||
{% for product in all_products %}
|
||||
<li>
|
||||
<h2>{{product.name}}</h2>
|
||||
Only {{product.price | price }}
|
||||
|
||||
{{product.description | prettyprint | paragraph }}
|
||||
|
||||
{{ 'it rocks!' | paragraph }}
|
||||
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
layout: null
|
||||
---
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ site.title | xml_escape }}</title>
|
||||
<description>{{ site.description | xml_escape }}</description>
|
||||
<link>{{ site.url }}{{ site.baseurl }}/</link>
|
||||
<atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
|
||||
<pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
|
||||
<lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
|
||||
<generator>Jekyll v{{ jekyll.version }}</generator>
|
||||
{% for post in site.posts limit:10 %}
|
||||
<item>
|
||||
<title>{{ post.title | xml_escape }}</title>
|
||||
<description>{{ post.content | xml_escape }}</description>
|
||||
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
|
||||
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
|
||||
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
|
||||
{% for tag in post.tags %}
|
||||
<category>{{ tag | xml_escape }}</category>
|
||||
{% endfor %}
|
||||
{% for cat in post.categories %}
|
||||
<category>{{ cat | xml_escape }}</category>
|
||||
{% endfor %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user