Help
{{{#help}}}
Available Handlebars Helpers
Available Handlebars Helpers
| Helper Name | Type | Example | Description |
|---|---|---|---|
| date | Inline | {{#date @DateTime}} | Formats a DateTime or DateTimeOffset to a short date string. |
| dateFormat | Inline | {{#dateFormat @DateTime "yyyy-MM-dd HH:mm"}} | Formats a DateTime or DateTimeOffset according to the specified format string. |
| encode | Inline | {{#encode @text}} | Encodes the text for HTML output, escaping special characters. |
| help | Inline | {{#help}} | Displays information about available helpers. |
| L | Inline | {{#L @string_key values[]?}} | Localization helper. Returns localized string by key. If values are provided, they will be used for formatting the string. |
| lookup | Inline | | |
| nl2br | Inline | {{#nl2br @text}} | Converts newlines in the text to <br> tags. |
| parsedateandformat | Inline | {{#parsedateandformat @string @parseformat @outformat}} | Parse string to date and formats a DateTime or DateTimeOffset to a short date string. |
| raw_block | Inline | {{#raw_block @block_name}} | Выводит содержимое блока с именем block_name. Блоки регистрируются в WebSiteTemplate.Parts |
| RenderPostContent | Inline | {{#RenderPostContent @postId}} | Отрисовывает содержимое Post исходя из настроек |
| site_footer | Inline | {{{#site_footer}}} | Writes HTML footer scripts. |
| site_head | Inline | {{{#site_head}}} | Writes HTML headers meta tags, scripts e.t.c. |
| striphtml | Inline | {{#striphtml @html}} | Strips HTML tags from the text. |
| text_ellipsis | Inline | {{#text_ellipsis @string @count?}} | Truncates the text to the specified character count, adding an ellipsis if necessary. |
| text_excerpt | Inline | {{#text_excerpt @string @count?}} | Generates an excerpt from the text, stripping HTML and truncating to the specified character count. |
| ToHumanizedSize | Inline | {{#ToHumanizedSize @size}} | Converts a size in bytes to a human-readable format. |
| tojson | Inline | {{#tojson @object}} | Serializes an object to JSON format. |
| youtubeId | Inline | {{#youtubeId @url}} | Extracts the YouTube video ID from a YouTube URL. |
| !mobile | Block | {{#!mobile}}...{{/!mobile}} | Печатает содержимое в блоке если запрос НЕ с мобильного устройства |
| and | Block | {{#and @args[]}} | Conditionally renders if all arguments are truthy. |
| Contains | Block | {{#contains @source @item}} | Conditionally renders if the source contains the item. |
| context | Block | {{#context @key? @cache?="10m"}}...{{/context}} | Контекстный блок. Позволяет использовать контекстные данные в шаблоне. Если указан ключ, то данные будут кэшироваться в памяти на указанный период времени |
| eq | Block | {{#eq @left @right}} | Conditionally renders if left == right. |
| eqstr | Block | {{#eqstr @left @right}} | Conditionally renders if left == right. |
| for | Block | {{#for @start @end @step?}} | Iterates from start to end. |
| gt | Block | {{#gt @left @right}} | Conditionally renders if left > right. |
| gte | Block | {{#gte @left @right}} | Conditionally renders if left >= right. |
| if_divided_by | Block | | |
| iff | Block | {{#iff 'x>y'}}...{{/iff}} | Условный блок. Выполняет содержимое, если условие истинно. Условие должно быть в кавычках |
| IsEmpty | Block | {{#isEmpty @value}} | Conditionally renders if the value is empty (null, empty string, empty collection). |
| lt | Block | {{#lt @left @right}} | Conditionally renders if left < right. |
| lte | Block | {{#lte @left @right}} | Conditionally renders if left <= right. |
| mobile | Block | {{#mobile}}...{{/mobile}} | Печатает содержимое в блоке если запрос с мобильного устройства |
| neq | Block | {{#neq @left @right}} | Conditionally renders if left != right. |
| neqstr | Block | {{#neqstr @left @right}} | Conditionally renders if left != right. |
| or | Block | {{#or @args[]}} | Conditionally renders if any argument is truthy. |
| with | Block | |
Registered #context functions
{{#context}}
x == 1 + 2
y == x*2
req = Req(...)
posts = ef.post.Take(10)
page == int.Parse(_req.Query["page"]??"1")
userId == _user.Id
{{/context}}
Registered #context functions
| Helper Name | Example | Description |
|---|---|---|
| Node | x = Node(callNodeName, payload? = null) | Вызов ноды CallNode с именем nodeName и передача ей необязательного параметра payload. Возвращает результат выполнения ноды. |
| Paginator | x = Paginator(@page?, total, pageSize) | Создает объект пагинатора для управления постраничным выводом данных. Если @page? не передат, то пытается прочитать _req.Query["page"]??1 |
| Req | x = Req("GET", "https://example.com/api/data", @postData?) | Выполняет HTTP запрос. |
| CalendarRow | | |
| RenderPostContent | html = RenderPostContent(@post.Id) | Render post content if provider support |
Registered #context ef Models
Registered #context ef Models
| Type name | Example | Description |
|---|---|---|
| post | posts = ef.post.Table(page, 20) | Записи |
| Users | users = ef.Users.Take(10) | |
| UserTypes | usertypes = ef.UserTypes.Take(10) | |
| Roles | roles = ef.Roles.Take(10) | |
| UserClaims | userclaims = ef.UserClaims.Take(10) | |
| UserRoles | userroles = ef.UserRoles.Take(10) | |
| UserLogins | userlogins = ef.UserLogins.Take(10) | |
| RoleClaims | roleclaims = ef.RoleClaims.Take(10) | |
| UserTokens | usertokens = ef.UserTokens.Take(10) | |
| UserPasskeys | userpasskeys = ef.UserPasskeys.Take(10) | |
| Options | options = ef.Options.Take(10) | |
| Files | files = ef.Files.Take(10) | |
| MediaFolders | mediafolders = ef.MediaFolders.Take(10) | |
| Posts | posts = ef.Posts.Take(10) | |
| PostTypes | posttypes = ef.PostTypes.Take(10) | |
| PostStatuses | poststatuses = ef.PostStatuses.Take(10) | |
| MetaFields | metafields = ef.MetaFields.Take(10) | |
| PostMetaValues | postmetavalues = ef.PostMetaValues.Take(10) | |
| PostTypePresentations | posttypepresentations = ef.PostTypePresentations.Take(10) | |
| MetaSequences | metasequences = ef.MetaSequences.Take(10) | |
| PostCategories | postcategories = ef.PostCategories.Take(10) | |
| PostCategoryTypes | postcategorytypes = ef.PostCategoryTypes.Take(10) | |
| PostCategoryMetaValues | postcategorymetavalues = ef.PostCategoryMetaValues.Take(10) | |
| UserMetaValues | usermetavalues = ef.UserMetaValues.Take(10) | |
| NavMenus | navmenus = ef.NavMenus.Take(10) | |
| Feedbacks | feedbacks = ef.Feedbacks.Take(10) |
Supported Query ef.<type>.<Method> methods
Supported Query ef.<type>.<Method> methods
| Helper Name | Example | Description |
|---|---|---|
| Count | .Count(@expr?) | Возвращает количество элементов в запросе. Если @expr не указано, то возвращает общее количество элементов в запросе |
| First | .First(@expr?) | Возвращает первый элемент. Если @expr указано, то возвращает применяет выборку. |
| Include | .Include(@expr) | Включает связанные данные в запрос. @expr - имя навигационного свойства или список свойств через запятую |
| Last | .Last(@expr?) | Возвращает последний элемент. Если @expr указано, то возвращает применяет выборку. |
| OrderBy | .OrderBy(@fieldName) | Сортирует элементы по указанному полю. @fieldName - имя поля для сортировки |
| OrderByDescending | .OrderByDescending(@fieldName) | Сортирует элементы по указанному полю в порядке убывания. @fieldName - имя поля для сортировки |
| Search | .Search(@searchText) | Поиск по тексту. @searchText - текст для поиска |
| Select | .Select(@expr) | Выбирает элементы из запроса по указанному выражению. @expr - выражение для выбора элементов |
| Skip | .Skip(@expr) | Пропускает указанное количество элементов. @expr - выражение для вычисления количества элементов для пропуска |
| Table | .Table(@page, @size) | Пагинация. Возвращает элементы в виде таблицы с пагинацией. @page - номер страницы, @size - количество элементов на странице |
| Take | .Take(@expr) | Ограничивает количество элементов в запросе. @expr - выражение для вычисления количества элементов для ограничения |
| ThenBy | .ThenBy(@fieldName) | Продолжает сортировку элементов по указанному полю. @fieldName - имя поля для сортировки |
| ThenByDescending | .ThenByDescending(@fieldName) | Продолжает сортировку элементов по указанному полю в порядке убывания. @fieldName - имя поля для сортировки |
| ToList | .ToList() | Преобразует запрос в список. |
| Union | .Union(@secondQueryable) | Объединяет текущий запрос с другим запросом. @secondQueryable - второй запрос для объединения |
| Where | .Where(@expr) | Фильтрует элементы по указанному выражению. @expr - выражение для фильтрации |
Useful tricks
| title | item |
|---|---|
| Uri id pattern |
@page "/posts/{id}"
|
| Uri Slug pattern |
@page "/posts/{Slug}"
|
| Paginator |
page == int.Parse(_req.Query["page"]??"1")
|
| Union |
posts = Union(myType.Where(post.pinned==true).Take(1), myType.OrderByDescending(Slug))
|
<pre>{{#tojson .}}</pre>
{
"$attr": {
"page": "/help",
"layout": "layout/base"
},
"_user": null,
"_req": {
"Query": {},
"QueryDict": [],
"HasFormContentType": false,
"ContentType": null,
"QueryString": "",
"Path": "/help",
"Host": {
"Value": "test2.my.mdimai666.ru",
"HasValue": true,
"Host": "test2.my.mdimai666.ru",
"Port": null
},
"IsHttps": false,
"Scheme": "http",
"Method": "GET",
"Form": null,
"RouteValues": null,
"IsMobile": false
},
"SiteSettings": {
"SiteUrl": "https://test2.my.mdimai666.ru",
"SiteName": "test2",
"SiteDescription": "New Mars website description",
"AdminEmail": "mdimai666@gmail.com",
"AllowUsersSelfRegister": false,
"Default_Role": "00000000-0000-0000-0000-000000000000"
},
"_dev": false,
"bodyClass": "",
"bodyAttrs": "",
"_lang": "ru",
"$errors": []
}