Builtin Functions
range
Returns a list of the specified specifications
parameters:
start: optional. Defaults to 0, the start valueend: mandatory, end value, exclude this numberstep_by: optional, defaults to 1, grows steps at a time
now
Return the current time, in date string or timestamp format.
Parameters:
timestamp: optional, defaultfalse, whether or not to return a timestamputc: optional, defaultfalse, whether or not to return the utc time
get_random
Get a random number in the range [start, end).
Parameters
start: optional, defaults to 0. Minimum value.end: maximum value, the range does not include this value.
get_env
Returns a system variable with the specified name.
Parameters:
name: The name of the variable.default: Use this default value if it does not exist.
assets
Output static resource references. Depends on assets-manifest.json in the template path, which is usually provided by the webpack plugin
webpack-assets-manifest
The plugin is configured as follows:
new WebpackAssetsManifest({
publicPath: true,
entrypoints: true,
output: 'assets-manifest.json',
}),
Parameters:
type: assets type. Valid valuesjsorcss.section: name of the entry (entrypoint).cdn: optional. Preferred CDN prefix for this resource. Note that the CDN prefix is only appended if it is a non-absolute path.
imgsrc
Get the url of the packaged image. The data comes from the img-manifest.json file, which is commonly used in the Manifest file output by Webpack after packaging a resource.
{# Use function explicitly #}
<img src="{{ imgsrc(file="a/b/logo.png") }}" />
{# Syntactic sugar for the above function, automatically converting addresses in "@" prefix format. #}
<img src="@a/b/logo.png" />
Parameters:
file: file path.
Priority will be given to files with language code file name suffixes when they exist.
For example, when the startup parameter is set to --lang=en_US
img-manifest.json
{
"assets/img/arrow-down.png": "assets/img/arrow-down.9685e4b1.png",
"assets/img/arrow-down.en_US.png": "assets/img/arrow-down.9685e4b1.en_US.png"
}
Templates
<img src="{{img_src(file='assets/img/arrow-down.png')}}" />
Output
<img src="assets/img/arrow-down.9685e4b1.en_US.png" />
t
Multi-language output.
<div class="">{{ t(text="meta description", memo="hello world") }}</div>
<div class="">{{ t(text="memo: body2 ") }}</div>
<script>var msg = "hello {{ __T_my name__ }}";</script>
Syntactic sugar: __T__label__, mostly used in js strings, label is a language keyword.
text: language content.memo: optional. Content annotations.
ds
Data source specification. Supports json, yaml, toml formats, which are automatically (by default, based on extension) converted to objects after loading. The data source can be a file in the local template directory or a remote Url address.
Parameters:
src: data source address.format: optional, inferred from the extension. Returns the parsed format of the content. Valid values are:json,yaml,toml,csv.bearer: optional, OAuth Token.post: optional, defaultfalse, whether it is a POST request.json_payload: optional, JSON data object sent by POST request.csv_delimiter: optional, CSV delimiter, default,.cache_secs: optional, time to cache in seconds. Default is not cached.
script
Javascript extension. The return value of the script can be a normal data type or a json object. Examples are shown below:
{% set hi_js = `
function sayHello(name){
return `hello ${name}`
}
sayHello(args.name)
` %}
<p>{{script(content=hi_js, name=file.name)}}</p>
Parameters:
content: content of the script.file: script file name. The script needs to be placed in the template directory_everkm/_js/.- Other parameter key-value pairs, converted to attributes of the JS global variable
args.
The content, file parameter is either one or the other.
base_url
The URL prefix of the exported page, mostly used for deploying to a secondary directory after export.
post_meta
Returns metadata for the specified content.
Parameters
path: content file path.
Return format
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| id | ID | String | Commonly used for parameter passing. | |
| title | title | string | ||
| dir | directory | String | with the characters / at the ends |
|
| path | file path | String | ||
| url_path | Front-end URL path | String | ||
| slug | File Slug | String | Defaults to header URL encoding | |
| summary | Summary | String | ||
| date | creation_time | time string | ||
| update_at | update time | time string | ✔️ | |
| draft | whether draft | boolean | ||
| tags | Tags | Array of strings | ||
| weight | weight | integer | ✔️ | Weights |
| meta | meta attributes | objects | ✔️ | FrontMatter for Markdown files, except for the key names listed in this table, which are used as subattributes of meta. |
post_detail
Content details
Parameters
path: mandatory. Content file path.lazy_img: Optional. Delayed loading of images.exclude_tags: Optional. Content block excludes tags. Multiple Tags are separated by spaces. Note: When the matching Tag is a title, that title and subordinate titles and content are ignored.
Return
Add the following to the content metadata
| key | meaning | type | optional | description |
|---|---|---|---|---|
| content_html | Detailed content after converting HTML | string |
post_exist
Whether the content exists
Parameters
path: The path to the content.
posts
Returns a list of articles with the specified conditions, in the format shown in post_meta.
The list sorting rules are: weight ↓, update_at|date ↓, title ↑, date ↓.
Parameters
dir: optional. Filter by directory.tags: optional. Filter by tags.recursive: optional, defaultfalse. Whether or not to recurse all descendant directories when filtering by directory.
Environmental Variables
EVERKM_DRAFT: Returns everything including drafts when value is1, default0.
posts_tag_list
Returns a list of tags and their corresponding file counts.
Parameters
| key | meaning | type | optional | description |
|---|---|---|---|---|
| dir | Directory | String | ✔️ | Starting with / |
Return
{
"<tag>": 1,
}
posts_caregory_list
Returns a list of categories and their corresponding file counts.
Parameters
| key | meaning | type | optional | description |
|---|---|---|---|---|
| dir | Directory | String | ✔️ | Starting with / |
Return
{
"<category>": 1,
}
posts_directory_list
Gets the collection of path for the specified condition.
Parameters
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| dir | Directory | String | ✔️ | Starting with / |
| max_depth | max_depth | positive integer | ✔️ | / for level 1 |
| prefix | limited prefix | string | ✔️ | starts with / |
Returns
Array of strings. Arranged in dictionary order.
[
"/blog/2013/",
"/docs/",
]
media_local
Localize remote image, audio, and video resources.
Parameters
url: remote address
Return
Object type.
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| url | local address | string |
media_dimension
Returns the dimensions of the image.
Parameters
file: absolute path to the file
Return format
Object type.
| key | meaning | type | optional | description |
|---|---|---|---|---|
| width | width | number | ||
| height | height | number |
nav_indicator
Returns the current page's front and back items in the navigation tree.
Parameters
from_file: absolute path to the navigation tree file
Return format
{
"prev": { // optional
"title": "Title",
"link": "link"
},
"next": { // optional
"title": "Title", "link": "Link".
"link": "link"
}, }
}
page_query
Modify the current page query parameters and output.
Parameters
All input parameters override to update the old parameter with the same name.
Returns
Modified parameter key-value pairs in application/x-www-form-urlencoded format.
oops
Terminates template parsing and displays an error message.
parameters
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| message | error message | string |
local_cfg
Get context-sensitive language configuration items.
Parameters
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| key | key name | string | Multi-level nesting Please use / segmentation, must start with /, follow RFC6901 standard. For example: /site/name. |
|
| default | Default value | Same as Constants type | ✔️ |
Returns
The value of key specified under __cfg in the configuration file everkm.yaml.
local_cfg_exist
Detecting the existence of a configuration item
Parameter
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| key | key name | string | same as local_cfg |
Returns
Boolean
src
Resource file references. Such as audio, video, PDF documents, etc.
Parameters
| Key | Meaning | Type | Optional | Description |
|---|---|---|---|---|
| file | file path | string | Relative paths are based on the directory of the markdown file to which they belong |
Returns
URL address, and the resource file is automatically packed into the publish directory when it is published.