NTypewriter functions
March 24, 2024 ยท View on GitHub
This file was auto generated from template : BuiltInFunctions.nt
NTypewriter functions
ActionFunctions
DebugFunctions
LINQFunctions
ParametersFunctions
StringFunctions
SymbolFunctions
SymbolsFunctions
- ThatAreNotStatic
- ThatArePublic
- ThatAreStatic
- ThatDoNotHaveAttribute
- ThatHaveAttribute
- WhereNameDoesNotEndWith
- WhereNameDoesNotMatch
- WhereNameDoesNotStartWith
- WhereNameEndsWith
- WhereNameMatches
- WhereNamespaceDoesNotEndWith
- WhereNamespaceDoesNotMatch
- WhereNamespaceDoesNotStartWith
- WhereNamespaceEndsWith
- WhereNamespaceMatches
- WhereNamespaceStartsWith
- WhereNameStartsWith
TypeFunctions
TypesFunctions
Scriban functions
ArrayFunctions
- Add
- AddRange
- Compact
- Concat
- Contains
- Cycle
- Each
- Filter
- First
- InsertAt
- Join
- Last
- Limit
- Map
- Offset
- RemoveAt
- Reverse
- Size
- Sort
- Uniq
HtmlFunctions
MathFunctions
RegexFunctions
StringFunctions
- Append
- Base64Decode
- Base64Encode
- Capitalize
- Capitalizewords
- Contains
- Downcase
- Empty
- EndsWith
- EqualsIgnoreCase
- Escape
- Handleize
- HmacSha1
- HmacSha256
- IndexOf
- Literal
- LStrip
- Md5
- PadLeft
- PadRight
- Pluralize
- Prepend
- Remove
- RemoveFirst
- RemoveLast
- Replace
- ReplaceFirst
- RStrip
- Sha1
- Sha256
- Size
- Slice
- Slice1
- Split
- StartsWith
- Strip
- StripNewlines
- ToDouble
- ToFloat
- ToInt
- ToLong
- Truncate
- Truncatewords
- Upcase
- Whitespace
TimeSpanFunctions
NTypewriter functions
ActionFunctions
BodyParameter
IParameter Action.BodyParameter(IMethod method)
Returns parameter that receives content sent to a webapi action in a request body. [source code]
HttpMethod
string Action.HttpMethod(IMethod method)
Returns the http method used with a webapi action. The http method is extracted from Http* or AcceptVerbs attribute or by naming convention if no attributes are specified. [source code]
Parameters
IEnumerable<IParameter> Action.Parameters(IMethod method, bool includeBodyParameter = true)
Returns parameters that receive content sent to a webapi action. If includeBodyParameter is specified as false, then the Parameter list returned will not include the parameter that is being sent in the body of the request. [source code]
ReturnType
IType Action.ReturnType(IMethod method)
Returns type that is returned from action unwrapped from Task and ActionResult generics [source code]
Url
string Action.Url(IMethod method)
Returns the url for the Web API action based on route attributes (or the supplied convention route if no attributes are present). Route parameters are converted to TypeScript string interpolation syntax by prefixing all parameters with {id}. Optional parameters are added as QueryString parameters for GET and HEAD requests. [source code]
DebugFunctions
Throw
void Debug.Throw(string message)
Throws exception and stops rendering [source code]
WriteLine
void Debug.WriteLine(MainTemplateContext context, string text)
Write text on NTypewriter output window [source code]
LINQFunctions
Where
IEnumerable<object> LINQ.Where(MainTemplateContext context, IEnumerable<object> source, string predicate)
Filters a sequence of values based on a predicate. Predicate uses C# lambda syntax, the same one that is used by LINQ Where method [source code]
ParametersFunctions
ToTypeScript
IEnumerable<string> Parameters.ToTypeScript(IEnumerable<IParameter> parameters, string nullableType = "null")
StringFunctions
SplitIntoSeparateWords
IEnumerable<string> String.SplitIntoSeparateWords(string text)
It tries to extract separate words from string [source code]
ToCamelCase
string String.ToCamelCase(string text)
Converts text case to CamelCase [source code]
ToLowerFirst
string String.ToLowerFirst(string text)
Converts first letter of the given string to lower case [source code]
ToUpperFirst
string String.ToUpperFirst(string text)
Converts first letter of the given string to upper case [source code]
SymbolFunctions
HasAttribute
bool Symbol.HasAttribute(ISymbolBase symbol, string attributeName)
Checks if symbol is decorated with an attribute [source code]
SymbolsFunctions
ThatAreNotStatic
IEnumerable<ISymbolBase> Symbols.ThatAreNotStatic(IEnumerable<ISymbolBase> symbols)
Filters symbols by the static modifier [source code]
ThatArePublic
IEnumerable<ISymbolBase> Symbols.ThatArePublic(IEnumerable<ISymbolBase> symbols)
Filters symbols by the public access modifier [source code]
ThatAreStatic
IEnumerable<ISymbolBase> Symbols.ThatAreStatic(IEnumerable<ISymbolBase> symbols)
Filters symbols by the static modifier [source code]
ThatDoNotHaveAttribute
IEnumerable<ISymbolBase> Symbols.ThatDoNotHaveAttribute(IEnumerable<ISymbolBase> symbols, string attributeName)
Filters symbols by the absence of an attribute [source code]
ThatHaveAttribute
IEnumerable<ISymbolBase> Symbols.ThatHaveAttribute(IEnumerable<ISymbolBase> symbols, string attributeName)
Filters symbols by the presence of an attribute [source code]
WhereNameDoesNotEndWith
IEnumerable<ISymbolBase> Symbols.WhereNameDoesNotEndWith(IEnumerable<ISymbolBase> symbols, string postfix)
Filters symbols by the end of their name [source code]
WhereNameDoesNotMatch
IEnumerable<ISymbolBase> Symbols.WhereNameDoesNotMatch(IEnumerable<ISymbolBase> symbols, string pattern)
Filters symbols by a regex pattern [source code]
WhereNameDoesNotStartWith
IEnumerable<ISymbolBase> Symbols.WhereNameDoesNotStartWith(IEnumerable<ISymbolBase> symbols, string prefix)
Filters symbols by the beginning of their name [source code]
WhereNameEndsWith
IEnumerable<ISymbolBase> Symbols.WhereNameEndsWith(IEnumerable<ISymbolBase> symbols, string postfix)
Filters symbols by the end of their name [source code]
WhereNameMatches
IEnumerable<ISymbolBase> Symbols.WhereNameMatches(IEnumerable<ISymbolBase> symbols, string pattern)
Filters symbols by a regex pattern [source code]
WhereNamespaceDoesNotEndWith
IEnumerable<ISymbolBase> Symbols.WhereNamespaceDoesNotEndWith(IEnumerable<ISymbolBase> symbols, string postfix)
Filters symbols by the end of their namespace [source code]
WhereNamespaceDoesNotMatch
IEnumerable<ISymbolBase> Symbols.WhereNamespaceDoesNotMatch(IEnumerable<ISymbolBase> symbols, string pattern)
Filters symbols by regex pattern [source code]
WhereNamespaceDoesNotStartWith
IEnumerable<ISymbolBase> Symbols.WhereNamespaceDoesNotStartWith(IEnumerable<ISymbolBase> symbols, string prefix)
Filters symbols by the beginning of their namespace [source code]
WhereNamespaceEndsWith
IEnumerable<ISymbolBase> Symbols.WhereNamespaceEndsWith(IEnumerable<ISymbolBase> symbols, string postfix)
Filters symbols by the end of their namespace [source code]
WhereNamespaceMatches
IEnumerable<ISymbolBase> Symbols.WhereNamespaceMatches(IEnumerable<ISymbolBase> symbols, string pattern)
Filters symbols by regex pattern [source code]
WhereNamespaceStartsWith
IEnumerable<ISymbolBase> Symbols.WhereNamespaceStartsWith(IEnumerable<ISymbolBase> symbols, string prefix)
Filters symbols by the beginning of their namespace [source code]
WhereNameStartsWith
IEnumerable<ISymbolBase> Symbols.WhereNameStartsWith(IEnumerable<ISymbolBase> symbols, string prefix)
Filters symbols by the beginning of their name [source code]
TypeFunctions
AllReferencedTypes
IEnumerable<IType> Type.AllReferencedTypes(IType type, SearchIn searchIn = SearchIn.All)
Returns all types that are used in definition of a given type. [source code]
ToTypeScriptDefault
string Type.ToTypeScriptDefault(IType type)
The default value of the type. (Dictionary types returns {}, enumerable types returns [], boolean types returns false, numeric types returns 0, void returns void(0), Guid types return empty guid string, Date types return new Date(0), all other types return null) [source code]
ToTypeScriptType
string Type.ToTypeScriptType(IType type, string nullableTypePostfix = "null")
Converts type name to typescript type name [source code]
Unwrap
IType Type.Unwrap(IType type)
Returns the first TypeArgument of a generic type or the type itself if it's not generic. [source code]
TypesFunctions
ThatImplement
IEnumerable<IType> Types.ThatImplement(IEnumerable<IType> types, string interfaceName)
Filters types based on if a type implements given interface (directly or indirectly) [source code]
ThatInheritFrom
IEnumerable<IType> Types.ThatInheritFrom(IEnumerable<IType> types, string baseTypeName)
Filters types based on if a type inherits directly from given type [source code]
Scriban functions
Following functions come from Scriban, and you can read more about them in Scriban documentation
ArrayFunctions
Add
IEnumerable Array.Add(IEnumerable list, object value)
Adds a value to the input list. Scriban documentation
AddRange
IEnumerable Array.AddRange(IEnumerable list1, IEnumerable list2)
Concatenates two lists. Scriban documentation
Compact
IEnumerable Array.Compact(IEnumerable list)
Removes any null values from the input list. Scriban documentation
Concat
IEnumerable Array.Concat(IEnumerable list1, IEnumerable list2)
Concatenates two lists. Scriban documentation
Contains
bool Array.Contains(IEnumerable list, object item)
Returns if a list contains a specific item.
Scriban documentation
Cycle
object Array.Cycle(TemplateContext context, SourceSpan span, IList list, object group = null)
Loops through a group of strings and outputs them in the order that they were passed as parameters. Each time cycle is called, the next string that was passed as a parameter is output. Scriban documentation
Each
ScriptRange Array.Each(TemplateContext context, SourceSpan span, IEnumerable list, object function)
Applies the specified function to each element of the input. Scriban documentation
Filter
ScriptRange Array.Filter(TemplateContext context, SourceSpan span, IEnumerable list, object function)
Filters the input list according the supplied filter function. Scriban documentation
First
object Array.First(IEnumerable list)
Returns the first element of the input list.
Scriban documentation
InsertAt
IEnumerable Array.InsertAt(IEnumerable list, int index, object value)
Inserts a value at the specified index in the input list.
Scriban documentation
Join
string Array.Join(TemplateContext context, SourceSpan span, IEnumerable list, string delimiter, object function = null)
Joins the element of a list separated by a delimiter string and return the concatenated string. Scriban documentation
Last
object Array.Last(IEnumerable list)
Returns the last element of the input list.
Scriban documentation
Limit
IEnumerable Array.Limit(IEnumerable list, int count)
Returns a limited number of elments from the input list Scriban documentation
Map
IEnumerable Array.Map(TemplateContext context, SourceSpan span, object list, string member)
Accepts an array element's attribute as a parameter and creates an array out of each array element's value. Scriban documentation
Offset
IEnumerable Array.Offset(IEnumerable list, int index)
Returns the remaining of the list after the specified offset Scriban documentation
RemoveAt
IList Array.RemoveAt(IList list, int index)
Removes an element at the specified index from the input list
Scriban documentation
Reverse
IEnumerable Array.Reverse(IEnumerable list)
Reverses the input list
Scriban documentation
Size
int Array.Size(IEnumerable list)
Returns the number of elements in the input list
Scriban documentation
Sort
IEnumerable Array.Sort(TemplateContext context, SourceSpan span, object list, string member = null)
Sorts the elements of the input list according to the value of each element or the value of the specified member of each element
Scriban documentation
Uniq
IEnumerable Array.Uniq(IEnumerable list)
Returns the unique elements of the input list.
Scriban documentation
HtmlFunctions
Escape
string Html.Escape(string text)
Escapes a HTML input string (replacing & by &amp;)
Scriban documentation
Strip
string Html.Strip(TemplateContext context, string text)
Removes any HTML tags from the input string Scriban documentation
UrlEncode
string Html.UrlEncode(string text)
Converts any URL-unsafe characters in a string into percent-encoded characters. Scriban documentation
UrlEscape
string Html.UrlEscape(string text)
Identifies all characters in a string that are not allowed in URLS, and replaces the characters with their escaped variants. Scriban documentation
MathFunctions
Abs
object Math.Abs(TemplateContext context, SourceSpan span, object value)
Returns the absolute value of a specified number. Scriban documentation
Ceil
double Math.Ceil(double value)
Returns the smallest integer greater than or equal to the specified number. Scriban documentation
DividedBy
object Math.DividedBy(TemplateContext context, SourceSpan span, double value, object divisor)
Divides the specified value by another value. If the divisor is an integer, the result will be floor to and converted back to an integer. Scriban documentation
Floor
double Math.Floor(double value)
Returns the largest integer less than or equal to the specified number. Scriban documentation
Format
string Math.Format(TemplateContext context, SourceSpan span, object value, string format, string culture = null)
Formats a number value with specified .NET standard numeric format strings Scriban documentation
IsNumber
bool Math.IsNumber(object value)
Returns a boolean indicating if the input value is a number Scriban documentation
Minus
object Math.Minus(TemplateContext context, SourceSpan span, object value, object with)
Subtracts from the input value the with value
Scriban documentation
Modulo
object Math.Modulo(TemplateContext context, SourceSpan span, object value, object with)
Performs the modulo of the input value with the with value
Scriban documentation
Plus
object Math.Plus(TemplateContext context, SourceSpan span, object value, object with)
Performs the addition of the input value with the with value
Scriban documentation
Random
object Math.Random(TemplateContext context, SourceSpan span, int minValue, int maxValue)
Creates a random number Scriban documentation
Round
double Math.Round(double value, int precision = 0)
Rounds a value to the nearest integer or to the specified number of fractional digits. Scriban documentation
Times
object Math.Times(TemplateContext context, SourceSpan span, object value, object with)
Performs the multiplication of the input value with the with value
Scriban documentation
Uuid
string Math.Uuid()
Creates a new UUID Scriban documentation
RegexFunctions
Escape
string Regex.Escape(string pattern)
Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $,., #, and white space) by replacing them with their escape codes. This instructs the regular expression engine to interpret these characters literally rather than as metacharacters.
Scriban documentation
Match
ScriptArray Regex.Match(TemplateContext context, string text, string pattern, string options = null)
Searches an input string for a substring that matches a regular expression pattern and returns an array with the match occurences. Scriban documentation
Matches
ScriptArray Regex.Matches(TemplateContext context, string text, string pattern, string options = null)
Searches an input string for multiple substrings that matches a regular expression pattern and returns an array with the match occurences. Scriban documentation
Replace
string Regex.Replace(TemplateContext context, string text, string pattern, string replace, string options = null)
In a specified input string, replaces strings that match a regular expression pattern with a specified replacement string. Scriban documentation
Split
ScriptArray Regex.Split(TemplateContext context, string text, string pattern, string options = null)
Splits an input string into an array of substrings at the positions defined by a regular expression match. Scriban documentation
Unescape
string Regex.Unescape(string pattern)
Converts any escaped characters in the input string. Scriban documentation
StringFunctions
Append
string String.Append(string text, string with)
Concatenates two strings Scriban documentation
Base64Decode
string String.Base64Decode(string text)
Decodes a Base64-encoded string to a byte array. The encoding of the bytes is assumed to be UTF-8. Scriban documentation
Base64Encode
string String.Base64Encode(string text)
Encodes a string to its Base64 representation. Its character encoded will be UTF-8. Scriban documentation
Capitalize
string String.Capitalize(string text)
Converts the first character of the passed string to a upper case character. Scriban documentation
Capitalizewords
string String.Capitalizewords(string text)
Converts the first character of each word in the passed string to a upper case character. Scriban documentation
Contains
bool String.Contains(string text, string value)
Returns a boolean indicating whether the input string contains the specified string value.
Scriban documentation
Downcase
string String.Downcase(string text)
Converts the string to lower case. Scriban documentation
Empty
bool String.Empty(string text)
Returns a boolean indicating whether the input string is an empty string. Scriban documentation
EndsWith
bool String.EndsWith(string text, string value)
Returns a boolean indicating whether the input string ends with the specified string value.
Scriban documentation
EqualsIgnoreCase
bool String.EqualsIgnoreCase(string text, string value)
Returns a boolean indicating whether the input string is equal to specified string 'value'. Comparison is case insensitive. Scriban documentation
Escape
string String.Escape(string text)
Escapes a string with escape characters. Scriban documentation
Handleize
string String.Handleize(string text)
Returns a url handle from the input string. Scriban documentation
HmacSha1
string String.HmacSha1(string text, string secretKey)
Converts a string into a SHA-1 hash using a hash message authentication code (HMAC). Pass the secret key for the message as a parameter to the function. Scriban documentation
HmacSha256
string String.HmacSha256(string text, string secretKey)
Converts a string into a SHA-256 hash using a hash message authentication code (HMAC). Pass the secret key for the message as a parameter to the function. Scriban documentation
IndexOf
int String.IndexOf(string text, string search, int? startIndex = null, int? count = null, string stringComparison = null)
Reports the zero-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position and examines a specified number of character positions. Scriban documentation
Literal
string String.Literal(string text)
Return a string literal enclosed with double quotes of the input string. Scriban documentation
LStrip
string String.LStrip(string text)
Removes any whitespace characters on the left side of the input string. Scriban documentation
Md5
string String.Md5(string text)
Computes the md5 hash of the input string
Scriban documentation
PadLeft
string String.PadLeft(string text, int width)
Pads a string with leading spaces to a specified total length. Scriban documentation
PadRight
string String.PadRight(string text, int width)
Pads a string with trailing spaces to a specified total length. Scriban documentation
Pluralize
string String.Pluralize(int number, string singular, string plural)
Outputs the singular or plural version of a string based on the value of a number. Scriban documentation
Prepend
string String.Prepend(string text, string by)
Concatenates two strings by placing the by string in from of the text string
Scriban documentation
Remove
string String.Remove(string text, string remove)
Removes all occurrences of a substring from a string. Scriban documentation
RemoveFirst
string String.RemoveFirst(string text, string remove)
Removes the first occurrence of a substring from a string. Scriban documentation
RemoveLast
string String.RemoveLast(string text, string remove)
Removes the last occurrence of a substring from a string. Scriban documentation
Replace
string String.Replace(string text, string match, string replace)
Replaces all occurrences of a string with a substring. Scriban documentation
ReplaceFirst
string String.ReplaceFirst(string text, string match, string replace, bool fromEnd = false)
Replaces the first occurrence of a string with a substring. Scriban documentation
RStrip
string String.RStrip(string text)
Removes any whitespace characters on the right side of the input string. Scriban documentation
Sha1
string String.Sha1(string text)
Computes the sha1 hash of the input string
Scriban documentation
Sha256
string String.Sha256(string text)
Computes the sha256 hash of the input string
Scriban documentation
Size
int String.Size(string text)
Returns the number of characters from the input string Scriban documentation
Slice
string String.Slice(string text, int start, int? length = null)
The slice returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring with the remaining characters will be returned. Scriban documentation
Slice1
string String.Slice1(string text, int start, int length = 1)
The slice returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring with the first character will be returned. Scriban documentation
Split
IEnumerable String.Split(string text, string match)
The split function takes on a substring as a parameter. The substring is used as a delimiter to divide a string into an array. You can output different parts of an array using array functions.
Scriban documentation
StartsWith
bool String.StartsWith(string text, string value)
Returns a boolean indicating whether the input string starts with the specified string value.
Scriban documentation
Strip
string String.Strip(string text)
Removes any whitespace characters on the left and right side of the input string. Scriban documentation
StripNewlines
string String.StripNewlines(string text)
Removes any line breaks/newlines from a string. Scriban documentation
ToDouble
object String.ToDouble(TemplateContext context, string text)
Converts a string to a double Scriban documentation
ToFloat
object String.ToFloat(TemplateContext context, string text)
Converts a string to a float Scriban documentation
ToInt
object String.ToInt(TemplateContext context, string text)
Converts a string to an integer Scriban documentation
ToLong
object String.ToLong(TemplateContext context, string text)
Converts a string to a long 64 bit integer Scriban documentation
Truncate
string String.Truncate(string text, int length, string ellipsis = null)
Truncates a string down to the number of characters passed as the first parameter. An ellipsis (...) is appended to the truncated string and is included in the character count Scriban documentation
Truncatewords
string String.Truncatewords(string text, int count, string ellipsis = null)
Truncates a string down to the number of words passed as the first parameter. An ellipsis (...) is appended to the truncated string. Scriban documentation
Upcase
string String.Upcase(string text)
Converts the string to uppercase Scriban documentation
Whitespace
bool String.Whitespace(string text)
Returns a boolean indicating whether the input string is empty or contains only whitespace characters. Scriban documentation
TimeSpanFunctions
FromDays
TimeSpan TimeSpan.FromDays(double days)
Returns a timespan object that represents a days interval
Scriban documentation
FromHours
TimeSpan TimeSpan.FromHours(double hours)
Returns a timespan object that represents a hours interval
Scriban documentation
FromMilliseconds
TimeSpan TimeSpan.FromMilliseconds(double millis)
Returns a timespan object that represents a milliseconds interval
Scriban documentation
FromMinutes
TimeSpan TimeSpan.FromMinutes(double minutes)
Returns a timespan object that represents a minutes interval
Scriban documentation
FromSeconds
TimeSpan TimeSpan.FromSeconds(double seconds)
Returns a timespan object that represents a seconds interval
Scriban documentation
Parse
TimeSpan TimeSpan.Parse(string text)
Parses the specified input string into a timespan object. Scriban documentation