Template Helper Functions

Kampose provides helper functions for Handlebars templates in themes. These functions simplify tasks like string manipulation, logical operations, and formatting, making template authoring easier.

Most helpers return values that can render directly or be used in Handlebars expressions. The helpers that render content directly to the output adjust to the current format and support all formats provided by Kampose.

String Helpers

String manipulation and formatting functions that transform text values and return processed strings.

HelperPurposeParametersReturns
formatConverts a value to a string with optional formattingvalue, format?string
upperCaseConverts a string to uppercasetextstring
lowerCaseConverts a string to lowercasetextstring
kebabCaseConverts a string to kebab-casetextstring
snakeCaseConverts a string to snake_casetextstring
titleCaseConverts a string to title casetextstring
splitSplits a string by a separatorinput, separatorstring[]
concatConcatenates string representation of some values into a single string...valuesstring
firstNonBlankReturns the first non-blank value...valuesstring?

Logical Helpers

Conditional logic and comparison functions that evaluate expressions and return boolean values. These helpers support truthiness evaluation and allow controlling template flow with complex conditional logic.

HelperPurposeParametersReturns
eqTests equalityvalue1, value2boolean
neTests inequalityvalue1, value2boolean
ltTests less thanvalue1, value2boolean
leTests less than or equalvalue1, value2boolean
gtTests greater thanvalue1, value2boolean
geTests greater than or equalvalue1, value2boolean
inTests value in collectionneedle, ...haystackboolean
notLogical NOTvalueboolean
andLogical AND...valuesboolean
orLogical OR...valuesboolean

Arithmetic Helpers

Arithmetic helpers provide basic mathematical operations for integer values.

HelperPurposeParametersReturns
incIncrements a numeric value by onevaluenumber
decDecrements a numeric value by onevaluenumber
addAdds two numeric valuesvalue1, value2number
subSubtracts a numeric value from anothervalue1, value2number
mulMultiplies two numeric valuesvalue1, value2number
divDivides one numeric value by anothervalue1, value2number
modModulus of two numeric valuesvalue1, value2number
absAbsolute value of a numeric valuevaluenumber

URL Helpers

URL generation and manipulation functions that handle path resolution and fragment extraction.

HelperPurposeParametersReturns
rootUrlReturns the root URL of the siteuri
rootRelativeUrlConverts site-relative URL to document-relativeuriuri
fragmentExtracts fragment (anchor) from a URL for linking to sectionsuristring?

Member Helpers

Member helpers work with .NET types, members, and references. These helpers provide language-specific rendering for code elements and provide proper URLs cross-referencing documentation pages.

HelperPurposeParametersReturns
memberDefinitionRenders definition of a type or type member according to language syntaxelementN/A
memberSignatureRenders signature of a namespace, type or type member according to language syntaxelementN/A
memberNameReturns name of a namespace, type or type member, including its declaring typeelementstring
memberUrlReturns URL to documentation page of a namespace, type, or type memberelementuri
memberCategoryReturns category of a namespace, type, or type memberelementstring

Utility Helpers

General utility functions for common operations including value selection, numeric manipulation, date formatting, and content processing.

HelperPurposeParametersReturns
isUndefinedChecks if a value is undefinedvalueboolean
isNullChecks if a value is nullvalueboolean
isOddChecks if an integer number is oddvalueboolean
selectSelects a value from choices based on a selectorselector, choice1, choice2, ...any
lenReturns the length of a string or arrayvaluenumber
nowReturns current date/time with formattingformat?string
jsonConverts value to JSON string representationvaluestring
literalRenders a value as a formatted literal constant in the target programming languagevalueN/A
crefRenders a link to the documentation of a code referencecrefN/A
markdownRenders block content in Markdown as output format(block helper)N/A
stripTagsRemoves HTML tags from block content(block helper)N/A