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.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
format | Converts a value to a string with optional formatting | value, format? | string |
upperCase | Converts a string to uppercase | text | string |
lowerCase | Converts a string to lowercase | text | string |
kebabCase | Converts a string to kebab-case | text | string |
snakeCase | Converts a string to snake_case | text | string |
titleCase | Converts a string to title case | text | string |
split | Splits a string by a separator | input, separator | string[] |
concat | Concatenates string representation of some values into a single string | ...values | string |
firstNonBlank | Returns the first non-blank value | ...values | string? |
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.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
eq | Tests equality | value1, value2 | boolean |
ne | Tests inequality | value1, value2 | boolean |
lt | Tests less than | value1, value2 | boolean |
le | Tests less than or equal | value1, value2 | boolean |
gt | Tests greater than | value1, value2 | boolean |
ge | Tests greater than or equal | value1, value2 | boolean |
in | Tests value in collection | needle, ...haystack | boolean |
not | Logical NOT | value | boolean |
and | Logical AND | ...values | boolean |
or | Logical OR | ...values | boolean |
Arithmetic Helpers
Arithmetic helpers provide basic mathematical operations for integer values.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
inc | Increments a numeric value by one | value | number |
dec | Decrements a numeric value by one | value | number |
add | Adds two numeric values | value1, value2 | number |
sub | Subtracts a numeric value from another | value1, value2 | number |
mul | Multiplies two numeric values | value1, value2 | number |
div | Divides one numeric value by another | value1, value2 | number |
mod | Modulus of two numeric values | value1, value2 | number |
abs | Absolute value of a numeric value | value | number |
URL Helpers
URL generation and manipulation functions that handle path resolution and fragment extraction.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
rootUrl | Returns the root URL of the site | uri | |
rootRelativeUrl | Converts site-relative URL to document-relative | uri | uri |
fragment | Extracts fragment (anchor) from a URL for linking to sections | uri | string? |
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.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
memberDefinition | Renders definition of a type or type member according to language syntax | element | N/A |
memberSignature | Renders signature of a namespace, type or type member according to language syntax | element | N/A |
memberName | Returns name of a namespace, type or type member, including its declaring type | element | string |
memberUrl | Returns URL to documentation page of a namespace, type, or type member | element | uri |
memberCategory | Returns category of a namespace, type, or type member | element | string |
Utility Helpers
General utility functions for common operations including value selection, numeric manipulation, date formatting, and content processing.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
isUndefined | Checks if a value is undefined | value | boolean |
isNull | Checks if a value is null | value | boolean |
isOdd | Checks if an integer number is odd | value | boolean |
select | Selects a value from choices based on a selector | selector, choice1, choice2, ... | any |
len | Returns the length of a string or array | value | number |
now | Returns current date/time with formatting | format? | string |
json | Converts value to JSON string representation | value | string |
literal | Renders a value as a formatted literal constant in the target programming language | value | N/A |
cref | Renders a link to the documentation of a code reference | cref | N/A |
markdown | Renders block content in Markdown as output format | (block helper) | N/A |
stripTags | Removes HTML tags from block content | (block helper) | N/A |
