Skip to content

Commit 4842f67

Browse files
committed
add more docs - drops, filters and endpoints
1 parent a2fe60a commit 4842f67

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

kms-drops.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## index
2+
Variable `index` accessible in templates and references to root page (with "index" slug). Object properties are the same as for `page` variable.
3+
4+
```handlebars
5+
{% for p in: index.children do: %}
6+
...
7+
{% end for %}
8+
```
9+
10+
## page
11+
Variable `page` can be accessed in any template and references to current page:
12+
13+
```handlebars
14+
{{ page.title }}
15+
```
16+
17+
Property of page | Description
18+
--- | ---
19+
slug | Value of "Slug" field
20+
fullpath | Page fullpath
21+
title | Value of "Title" field
22+
published | Value of "Published" field
23+
hidden | Value of "Hidden (from navigation)" field
24+
templatable | Value of "Use as object template" field
25+
children | Returns "children" collection - pages having this page as parent in "Parent page" field
26+
parent | Parent page reference
27+
28+
## request
29+
Variable `request` gives an access to some properties of current request:
30+
31+
```handlebars
32+
{{ request.form_authenticity_token }}
33+
```
34+
35+
Property of request | Description
36+
--- | ---
37+
path | Returns request relative path
38+
url | Returns request URL
39+
host | Returns host - domain name or IP address
40+
base_url | Returns request root URL - protocol + domain name or IP, ex., "http://example.com"
41+
referer | Returns URL of page that initiated current request
42+
form_authenticity_token | Returns authenticity token for current request - for form protection from CSRF attack
43+
param() | Returns URL param. Example: request.param('page')
44+
45+
## item
46+
Variable `item` gives access to current object of "templatable" page. "Templatable" - page with enabled "Use as object template" field and chosen object in "Object" field. Properties of `item` depend on concrete object. Please check out [KMS Models](/kms-models)
47+
48+
```handlebars
49+
{{ item.title }}
50+
```

kms-filters.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## asset_path
2+
Filter `asset_path` allows to get a relative path to any file from "Assets" section by filename:
3+
4+
```handlebars
5+
<img src="{{ 'logo.png' | asset_path }}">
6+
```
7+
8+
## asset_tag
9+
Filter `asset_tag` allows to include javascript and css files, uploaded to "Assets" section:
10+
11+
```handlebars
12+
{{ 'bootstrap.min.css' | asset_tag }}
13+
```
14+
15+
## resize
16+
This function/filter helps to change image size on-the-fly. For this filter you need to use absolute URL of image and "format" argument. Returns also URL. To get absolute URL (having only relative - any asset from "Assets") you should use `request.base_url`:
17+
18+
```handlebars
19+
{{ 'http://example.com/image.png' | resize format: '100x100' }}
20+
{{ (request.base_url + item.image) | resize format: '100x100' }}
21+
```
22+
23+
## add_watermark
24+
It allows to add watermark to image. You need image URL and 3 arguments: "image" - watermark image (watermark), "dissolve" - transparency and "position" - position. Returns also URL:
25+
26+
```handlebars
27+
{{ 'http://example.com/image.png' | add_watermark image: 'http://example.com/watermark.png' dissolve: '50%' position: 'center' }}
28+
```
29+
30+
## ends_with
31+
Allows to check if string ends with some pattern:
32+
33+
```handlebars
34+
{% if ends_with(media_item.file pattern: 'mp4') then: %}
35+
```
36+
37+
## currency
38+
Formats currency values. Possible options: precision, delimiter, separator, format, unit:
39+
40+
```handlebars
41+
# item.price is 100.0
42+
{{ item.price | currency precision: 0 }}
43+
# result - "100 руб."
44+
```

kms-models-drops.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## models
2+
Variable `models` gives access to models collections of entries. You can access collection using model collection name - "Collection name (for Liquor)" field. For example, if you created some Model with "services" collection name, then you could iterate its collection using "for" tag like this:
3+
4+
```handlebars
5+
{% for service in: models.services do: %}
6+
```

kms-models-endpoints.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## POST /entries/:collection_name
2+
This endpoint allows you to setup form submitting Model's elements. For example, if you have a model with collection name "posts" (and field with "title" Liquor name), you could create a form with action="/entries/posts" and an input with name="entry[title]"
3+
4+
```html
5+
<form action="/entries/:collection_name" method="post">
6+
<input type="hidden" name='authenticity_token' value='{{ request.form_authenticity_token }}'>
7+
<input type="text" name="entry[name]">
8+
<input type="submit" value="Send">
9+
</form>
10+
```

sidebar.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
- Liquor
55
- [Tags](/tags)
66
- [Variables](/variables)
7+
- KMS
8+
- [Drops](/kms-drops)
9+
- [Filters](/kms-filters)
10+
- KMS Models
11+
- [Drops](/kms-models-drops)
12+
- [Endpoints](/kms-models-endpoints)
713
- Extensions
814
- [Creating extension](/new-extension)

0 commit comments

Comments
 (0)