Help


{{{#help}}}
Available Handlebars Helpers

Available Handlebars Helpers

Helper Name Type Example Description
dateInline{{#date @DateTime}}Formats a DateTime or DateTimeOffset to a short date string.
dateFormatInline{{#dateFormat @DateTime "yyyy-MM-dd HH:mm"}}Formats a DateTime or DateTimeOffset according to the specified format string.
encodeInline{{#encode @text}}Encodes the text for HTML output, escaping special characters.
helpInline{{#help}}Displays information about available helpers.
LInline{{#L @string_key values[]?}}Localization helper. Returns localized string by key. If values are provided, they will be used for formatting the string.
lookupInline
nl2brInline{{#nl2br @text}}Converts newlines in the text to <br> tags.
parsedateandformatInline{{#parsedateandformat @string @parseformat @outformat}}Parse string to date and formats a DateTime or DateTimeOffset to a short date string.
raw_blockInline{{#raw_block @block_name}}Выводит содержимое блока с именем block_name. Блоки регистрируются в WebSiteTemplate.Parts
RenderPostContentInline{{#RenderPostContent @postId}}Отрисовывает содержимое Post исходя из настроек
site_footerInline{{{#site_footer}}}Writes HTML footer scripts.
site_headInline{{{#site_head}}}Writes HTML headers meta tags, scripts e.t.c.
striphtmlInline{{#striphtml @html}}Strips HTML tags from the text.
text_ellipsisInline{{#text_ellipsis @string @count?}}Truncates the text to the specified character count, adding an ellipsis if necessary.
text_excerptInline{{#text_excerpt @string @count?}}Generates an excerpt from the text, stripping HTML and truncating to the specified character count.
ToHumanizedSizeInline{{#ToHumanizedSize @size}}Converts a size in bytes to a human-readable format.
tojsonInline{{#tojson @object}}Serializes an object to JSON format.
youtubeIdInline{{#youtubeId @url}}Extracts the YouTube video ID from a YouTube URL.
!mobileBlock{{#!mobile}}...{{/!mobile}}Печатает содержимое в блоке если запрос НЕ с мобильного устройства
andBlock{{#and @args[]}}Conditionally renders if all arguments are truthy.
ContainsBlock{{#contains @source @item}}Conditionally renders if the source contains the item.
contextBlock{{#context @key? @cache?="10m"}}...{{/context}}Контекстный блок. Позволяет использовать контекстные данные в шаблоне. Если указан ключ, то данные будут кэшироваться в памяти на указанный период времени
eqBlock{{#eq @left @right}}Conditionally renders if left == right.
eqstrBlock{{#eqstr @left @right}}Conditionally renders if left == right.
forBlock{{#for @start @end @step?}}Iterates from start to end.
gtBlock{{#gt @left @right}}Conditionally renders if left > right.
gteBlock{{#gte @left @right}}Conditionally renders if left >= right.
if_divided_byBlock
iffBlock{{#iff 'x>y'}}...{{/iff}}Условный блок. Выполняет содержимое, если условие истинно. Условие должно быть в кавычках
IsEmptyBlock{{#isEmpty @value}}Conditionally renders if the value is empty (null, empty string, empty collection).
ltBlock{{#lt @left @right}}Conditionally renders if left < right.
lteBlock{{#lte @left @right}}Conditionally renders if left <= right.
mobileBlock{{#mobile}}...{{/mobile}}Печатает содержимое в блоке если запрос с мобильного устройства
neqBlock{{#neq @left @right}}Conditionally renders if left != right.
neqstrBlock{{#neqstr @left @right}}Conditionally renders if left != right.
orBlock{{#or @args[]}}Conditionally renders if any argument is truthy.
withBlock
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
Nodex = Node(callNodeName, payload? = null)Вызов ноды CallNode с именем nodeName и передача ей необязательного параметра payload. Возвращает результат выполнения ноды.
Paginatorx = Paginator(@page?, total, pageSize)Создает объект пагинатора для управления постраничным выводом данных. Если @page? не передат, то пытается прочитать _req.Query["page"]??1
Reqx = Req("GET", "https://example.com/api/data", @postData?)Выполняет HTTP запрос.
CalendarRow
RenderPostContenthtml = RenderPostContent(@post.Id)Render post content if provider support
Registered #context ef Models

Registered #context ef Models

Type name Example Description
postposts = ef.post.Table(page, 20)Записи
Usersusers = ef.Users.Take(10)
UserTypesusertypes = ef.UserTypes.Take(10)
Rolesroles = ef.Roles.Take(10)
UserClaimsuserclaims = ef.UserClaims.Take(10)
UserRolesuserroles = ef.UserRoles.Take(10)
UserLoginsuserlogins = ef.UserLogins.Take(10)
RoleClaimsroleclaims = ef.RoleClaims.Take(10)
UserTokensusertokens = ef.UserTokens.Take(10)
UserPasskeysuserpasskeys = ef.UserPasskeys.Take(10)
Optionsoptions = ef.Options.Take(10)
Filesfiles = ef.Files.Take(10)
MediaFoldersmediafolders = ef.MediaFolders.Take(10)
Postsposts = ef.Posts.Take(10)
PostTypesposttypes = ef.PostTypes.Take(10)
PostStatusespoststatuses = ef.PostStatuses.Take(10)
MetaFieldsmetafields = ef.MetaFields.Take(10)
PostMetaValuespostmetavalues = ef.PostMetaValues.Take(10)
PostTypePresentationsposttypepresentations = ef.PostTypePresentations.Take(10)
MetaSequencesmetasequences = ef.MetaSequences.Take(10)
PostCategoriespostcategories = ef.PostCategories.Take(10)
PostCategoryTypespostcategorytypes = ef.PostCategoryTypes.Take(10)
PostCategoryMetaValuespostcategorymetavalues = ef.PostCategoryMetaValues.Take(10)
UserMetaValuesusermetavalues = ef.UserMetaValues.Take(10)
NavMenusnavmenus = ef.NavMenus.Take(10)
Feedbacksfeedbacks = 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}"
post = news.First(post.Id == Guid.Parse(id))
Uri Slug pattern @page "/posts/{Slug}"
post = ef.post.First(post.Slug.ToLower() == Slug.ToLower())
Paginator page == int.Parse(_req.Query["page"]??"1")
table = ef.post.OrderByDescending(CreatedAt).Table(page,10)
posts == table.Items
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": []
        }