Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 1.46 KB

kms-scopes.md

File metadata and controls

69 lines (50 loc) · 1.46 KB

find_by

find_by allows you to find one element in collection by some condition/criteria.

{% assign news_page = index.children.find_by(title: 'News') %}

find_all_by

find_all_by finds all collection elements matching criterias

{% for p in: index.children.find_all_by(published: true) do: %}

except

except returns you all collection elements except ones provided as argument

{% assign correct_pages = index.children.except(excepted_page) %}

find_except_by

find_except_by finds all collection elements not matching provided criterias

{% for p in: index.children.find_except_by(hidden: true) do: %}

limit

limit method is equal to SQL limit so it allows to limit number of collection items

{% for post in: models.posts.limit(3) do: %}

offset

offset method is equal to SQL offset so it allows to fetch records by offset

{% for post in: models.posts.limit(3).offset(3) do: %}

first

returns first element in collection

{% assign first_post = models.posts.first %}

last

returns last element in collection

{% assign last_post = models.posts.last %}

[]

returns element by its index

{% assign third_post = models.posts[2] %}

pluck

returns collection containing elements specific field values (not full object)

{% for post_title in: models.posts.pluck('title') %}