Skip to content

Template API Helper Functions

Paul G.B edited this page Jun 25, 2020 · 3 revisions

Table of Contents

Template API Helper Functions

The following subsections are functions that can be used in template files to help with things such as creating hypertext links to external and internal types.

Capitalize

capitalize as (function): Capitalizes the given string, turning hello-world to Hello World.

function capitalize(val) { ... }
  • Parameter: val as (string): The value used to capitalize.
  • Returns: Returns the capitalized string.

Create Anchor to Type

createAnchorToType as (function): Creates an anchor tag to the type (includes using the type name).

function createAnchorToType(typeInfo, options) { ... }
function createAnchorToType(typeInfo) { ... }
  • Parameter: typeInfo as (QuickTypeInfo): The quick look into the type to look into.
  • Parameter: options as (any): Extra options to apply to the returning anchor type. The following options are used:
    • classes as (string): The list of classes to apply to the returning tag, seperated by spaces.
    • useFullName as (boolean): Set to true if the content of the anchor will use the full name instead of just the shortened name.
  • Returns: Returns an anchor tag to the type with a link.

Create Link to Type

createLinkToType as (function): Creates a internal or external link to the given type.

function createLinkToType(typePath) { ... }
  • Parameter: typePath as (string): The type path to create a link from.
  • Returns: Returns an http(s) link to where the type is found.

Create Partial

createPartial as (function): Creates a partial using the type and location to the template file.

function createPartial(type, url, context) { ... }
  • Parameter: type as (string): The type to create from (type, field, property, event, method).
  • Parameter: url as (string): The location of the template file to use.
  • Parameter: context as (any): The context used to pass over to the next template.
  • Returns: Returns the compiled template code.

Display Sidebar

displaySidebar as (function): Generates the html code for the sidebar tree view. This will only be available for navigation templates.

function displaySidebar(treeview, treeviewClass, nestedViewClass) { ... }
function displaySidebar(treeview, treeviewClass) { ... }
function displaySidebar(treeview) { ... }
  • Parameter: treeview as (Sideview or SidebarView[]): The sidebar tree view to traverse through and generate with.
  • Parameter: treeviewClass as (string): The class name for the top view of the list items. Defaults to "treeview".
  • Parameter: nestedviewClass as (string): The class name for the nested view of the list items. Defaults to "nested".
  • Returns: Returns the html code for the sidebar tree view.

Get ID From

getIdFrom as (function): Gets the id from the given details.

function getIdFrom(details) { ... }

Get Parameter Type

getParameterType as (function): Gets the parameter type from the given name.

function getParameterType(parameters, name) { ... }
  • Parameter: parameters as (ParameterInfo[]): The list of parameters to look into.
  • Parameter: name as (string): The name of the parameter to look into.
  • Returns: Returns the type info of the parameter.

Is Generic Type

isGenericType as (function): Finds if the given parameter's type is a generic type.

function isGenericType(parameter, xmlDocs) { ... }
  • Parameter: parameter as (ParameterNameDescription): The parameter to look into.
  • Parameter: xmlDocs as (XmlDocItems): The xml docs to look into.
  • Returns: Returns true if the parameter's type is generic.