Skip to main content
Templates are a fundamental component of the Tyk Enterprise Developer Portal, enabling dynamic content generation and customization. The portal uses Golang templates to render the live portal views, allowing you to generate dynamic HTML by embedding directives inside HTML that are replaced with values when the template is executed. Golang’s templates use the following syntax:
  • {{ . }} to output a value
  • {{ .FieldName }} to access a field of an object
  • {{ .MethodName }} to call a method on an object
  • {{ if }} {{ else }} {{ end }} for conditionals
  • {{ range . }} {{ . }} {{ end }} to iterate over a slice
  • Functions can be called like {{ FuncName . }} or just {{ FuncName }}
These templates are part of the default theme that ships with the portal, which can be fully customized by modifying the template files. The templates have access to template data which contains dynamic values that can be rendered into the HTML. There are also a number of global helper functions available to transform data before output. The Tyk Enterprise Developer Portal uses several types of templates to render different parts of the portal:
  • Public Pages Templates: Render the portal’s publicly accessible pages (such as Home, About Us, and Blog pages), forming the foundation of your portal’s public-facing content. These can be customized through the Pages section of the admin dashboard.
  • Private Pages Templates: Responsible for rendering the portal’s authenticated user pages, like Profile settings and My Apps.
  • Email Templates: Define the structure and content of emails sent by the portal, such as signup confirmations or access request approvals.
Both Public and Private Pages Templates have access to global helper functions (funcmaps) and template-specific data. Email templates can include template data and specific template functions, but do not have access to the global helper functions. The following sections provide comprehensive information on the various components of the Tyk Enterprise Developer Portal templates:
  • Template Data: Detailed explanation of the data structures available in different templates.
  • Global Helper Functions: A list of global functions that can be used across templates to manipulate and display data.
  • Email Templates: Information about email-specific templates and their available data.

Template Data

This section outlines the Tyk Enterprise Developer Portal templates that have access to specific template data. It’s important to note that data availability varies between templates, depending on their context and purpose. For instance, a product detail template has access to product-specific data that may not be available in a blog listing template.

Templates with specific template data

Analytics

Template Path: themes/default/views/analytics.tmpl This template is used to render the analytics page.

Available Objects

  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
  • {{ .apps }}: List of available applications

Application Attributes

Accessible via {{ range .apps }}
Example Usage

Application Create

Template Path: themes/default/views/app_form_create.tmpl This template is used to render the application creation form.

Available Objects

  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
Example Usage

Application Detail

Template Path: themes/default/views/app_form_update.tmpl This template is used to render the application detail and update form.

Available Objects

  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
  • {{ .app }}: Selected application object.
  • {{ .appCerts }}: Map of application MTLS certificates if applicable (Key: access request ID, Value: certificate)
  • {{ .allCerts }}: Map of all MTLS certificates stored if applicable (Key: cert fingerprint, Value: cert)

MTLS Certificate Attributes (appCerts)

MTLS Certificate Attributes (allCerts)

Client Attributes

Accessible via {{ .app }}

Client Credentials Attributes

Accessible via {{ range $cred := .app.Credentials }}

Client Access Requests Attributes

Accessible via {{ range $acreq := .app.AccessRequests }}

Product Attributes (within Access Request)

Accessible via {{ $product := $acreq.Product }}

Plan Attributes (within Access Request)

Accessible via {{ $acreq.Plan }}
Example Usage

Blogs

Template Path: themes/default/views/blog_listing.tmpl This template is used to render the blog listing page.

Available Objects

  • {{ .posts }}: List of all published blog posts

Blog Attributes

Accessible via {{ range .posts }}
Example Usage

Blog Detail

Template Path: themes/default/views/blog_detail.tmpl This template is used to render the blog detail page.

Available Objects

  • {{ .post }}: The selected blog post object.
  • {{ .latest_posts }}: List of 3 latest blog posts.

Blog Attributes

Accessible via {{ .post }} or {{ range .latest_posts }}
Example Usage

Cart Checkout

Template Path: themes/default/views/portal_checkout.tmpl This template is used to render the cart checkout page.

Available Objects

  • {{ .cart }}: Map with the cart items for the current user
  • {{ .apps }}: List of applications for the current user
  • {{ .catalogue_count }}: Cart catalogues count
  • {{ .certs }}: List of MTLS certificates if applicable
  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
  • {{ .provisioned }}: Boolean indicating whether an access request has been provisioned for the cart

Application Attributes

Accessible via {{ range .apps }}

MTLS Certificate Attributes

Accessible via {{ range .certs }}

Cart Item Attributes

Accessible via {{ range $key, $value := .cart }}

Plan Attributes (Within cart item)

Accessible via {{ $plan := $value.Plan }}

Catalogue Attributes (Within cart item)

Accessible via {{ $catalogue := $value.Catalogue }}

Product Attributes (Within cart item)

Accessible via {{ range $product := $value.Products }}

Auth Type Attributes (Within product)

Accessible via {{ range $auth_type := $product.AuthTypes }}

DCR Client Template Attributes (Within product)

Accessible via {{ range $template := $product.Templates }}

Organization User Detail

Template Path: themes/default/views/user_detail.tmpl This template is used to render the organization user detail page.

Available Objects

  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
  • {{ .user }}: The organization user object.

User Attributes

Accessible via {{ .user }}

Organization User Edit

Template Path: themes/default/views/user_edit.tmpl This template is used to render the edit page for organization user.

Available Objects

  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
  • {{ .roles }}: List of possible roles
  • {{ .user }}: The organization user object.

Role Attributes

Accessible via {{ range .roles }}

User Attributes

Accessible via {{ .user }}

Organization Users List

Template Path: themes/default/views/user_list.tmpl This template is used to render the list of organization users.

Available Objects

  • {{ .roles }}: Map of available roles (Key: role, Value: role display name)
Example Usage

Product Detail

Template Path: themes/default/views/portal_product_detail.tmpl This template is used to render the product detail page.

Available Objects

  • {{ .product }}: The selected product object
  • {{ .catalogues }}: List of catalogue objects including the selected product
  • {{ .unique_plans }}: List of plan objects available for the product
  • {{ .scopes }}: Product scopes as an array of strings
  • {{ .posts }}: List of related blog post objects
  • {{ .errors }}: Map of template errors (Key: category, Value: error message)
  • {{ .added }}: Boolean indicating if the product is added to the cart

Product Attributes

Accessible via {{ .product }}

API Details (Within product)

Accessible via {{ .product.APIDetails }}

Documentation (Within product)

Accessible via {{ .product.Docs }}

Product Tags (Within product)

Accessible via {{ .product.Tags }}

Catalogues

Accessible via {{ range .catalogues }}

Plans

Accessible via {{ range .unique_plans }} Accessible via {{ range .posts }}

Product OAS Documentation

Template Paths:
  • themes/default/views/product_doc_stoplight_spec.tmpl
  • themes/default/views/product_doc_redoc.tmpl
These templates are used to render the OpenAPI Specification (OAS) documentation for a product. The Stoplight Spec and ReDoc versions are available.

Available Attributes

Global Helper Functions

This section provides a detailed overview of the global helper functions available in the Tyk Enterprise Developer Portal templates. These functions are accessible across the public and private templates and allow you to perform various operations, retrieve specific data, and create dynamic content within your templates.

Available Functions

CanCreateOrganisation

Returns true if user can create an organization.
Example Usage

Clients

Returns the list of applications for the current user. Expects the request as argument.
Client Attributes
Accessible via {{ range $client := Clients req }}
Credential Attributes (Within client)
Accessible via {{ range $cred := $client.Credentials }}
Access Request Attributes (Within client)
Accessible via {{ range $acreq := $client.AccessRequests }}
Product Attributes (Within access request)
Accessible via {{ range $product := $acreq.Products }}
Plan Attributes (Within access request)
Accessible via {{ $acreq.Plan }}
Example Usage

CurrentUser

The CurrentUser function returns the current user object if a user is logged in. It expects the request as an argument.

User Attributes

Accessible via {{ $user := CurrentUser req }}
Example Usage

FeaturedProducts

Returns a list of featured products.
Product Attributes
Accessible via {{ range FeaturedProducts }}
API Details Attributes (Within product)
Accessible via {{ range .APIDetails }}
Catalogue Attributes (Within product)
Accessible via {{ range .Catalogues }}

FilterUserInvites

Returns a list of users that were invited to the current user’s organization, if the user became an organization. Expects the request as a parameter.
User Attributes
Accessible via {{ range $invite := FilterUserInvites req }}

FormatTime

Formats a given time with a given format.
Example Usage

GetCart

Returns a map with the cart items for a given user ID. Expects the user ID as an argument. This function is useful for retrieving and displaying the contents of a user’s cart, including detailed information about the products, their authentication types, and associated templates.
Cart Item Attributes
Accessible via {{ range $key, $value := GetCart $user.ID }}

Plan Attributes (Within cart item)

Accessible via {{ $plan := $value.Plan }}

Catalogue Attributes (Within cart item)

Accessible via {{ $catalogue := $value.Catalogue }}
Product Attributes (Within cart item)
Accessible via {{ range $product := $value.Products }}
DCR Client Template Attributes (Within product)
Accessible via {{ range $template := $product.Templates }}
Example Usage

GetCatalogueList

Returns a list of catalogue names. Expects the request as parameter.
Example Usage

GetCataloguesForProduct

Returns a list of products for a given user and product ID. Expects the request, a user and a product ID as parameters.
Catalogue Attributes
Accessible via {{ range GetCataloguesForProduct req $user $product.ID }}
Example Usage

GetClientDescription

Returns an application description given a credential ID.
Example Usage

GetClientName

Returns an application name given a credential ID.
Example Usage

GetMenus

Returns a map of all menus.
Example Usage

GetProducts

Returns the list of products for the current user. Expects the request as an argument.
Product Attributes
Accessible via {{ range $product := GetProducts req }}
API Details Attributes (Within product)
Accessible via {{ range $api := $product.APIDetails }}
Catalogue Attributes (Within product)
Accessible via {{ range $catalogue := $product.Catalogues }}

IsPortalDisabled

Returns true (exception: for admins is always enabled) if portal visibility was set to hidden. Expects the request as parameter.
Example Usage

IsPortalPrivate

Returns true (exception: for admins is always enabled) if portal visibility was set to private. Expects the request as parameter.
Example Usage

ProductDocRenderer

Returns the configured product OAS renderer (redoc or stoplight).
Example Usage

ProviderUpstreamURL

Returns the provider upstream URL for a given providerID. Expects the request and a provider ID as parameters.
Example Usage

SplitStrings

Splits a given string with given separator and returns a slice of split strings.
Example Usage

TruncateString

Truncates a given string to a given length, returning the truncated string followed by three dots (…).
Example Usage

TypeOfCredential

Returns the credential type (“oAuth2.0” or “authToken”) given the credential.
Example Usage

Email Templates

This section provides a detailed overview of the email template data available in the Tyk Enterprise Developer Portal. The Tyk Enterprise Developer Portal uses a variety of email templates for different purposes, such as user registration and access request status or organization status updates. Each template has access to specific data or functions relevant to its purpose. It’s important to note that while email templates can include template data or specific template functions, they do not have access to the global helper functions available in other portal templates. Please refer to email workflow for additional detail on email notifications sent by the portal.

Available Email Templates

Access Request Approve/Reject

Template Paths:
  • themes/default/mailers/approve.tmpl
  • themes/default/mailers/reject.tmpl
These templates are used for sending notifications to users when their access requests are approved or rejected.
Available Objects
There’s no data sent to these templates.
Example Usage

Access Request Submitted

Template Path: themes/default/mailers/submitted.tmpl This template is used for notifying administrators about pending access requests.
Available Objects
  • {{ .requests }}: Returns the list of access requests pending approval.
Access Request Attributes
Accessible via {{ range .requests }}
Product Attributes (within Access Request)
Accessible via {{ range $product := $acreq.Products }}
Example Usage

Activate and Deactivate

Template Paths:
  • themes/default/mailers/activate.tmpl
  • themes/default/mailers/deactivate.tmpl
These templates are used for sending activation and deactivation notifications to users.
Available Objects
  • {{ .name }}: Returns the user’s full name.
Example Usage

New User Request

Template Path: themes/default/mailers/newuser.tmpl This template is used for notifying administrators about new user registration requests pending activation.
Available Objects
  • {{ .user }}: Returns the new user pending activation.

User Attributes

Accessible via {{ .user }}
Example Usage

Organization Approve

Template Path: themes/default/mailers/organisation_request.tmpl This template is used for notifying users that their organization creation request has been approved.
Available Objects
  • {{ site }}: Returns the application host.
Example Usage

Organization Reject

Template Path: themes/default/mailers/organisation_reject.tmpl This template is used for notifying users that their organization creation request has been rejected.
Available Objects
There’s no data sent to this template.
Example Usage

Organization Request

Template Path: themes/default/mailers/organisation_request.tmpl This template is used for notifying administrators about new organization creation requests.
Available Objects
  • {{ .user }}: Returns the user who made the request.
  • {{ .organisationName }}: Returns the new organization name.

User Attributes

Accessible via {{ .user }}
Example Usage

Reset Password

Template Path: themes/default/mailers/auth/reset_password.tmpl This template is used for sending password reset emails to users.
Available Functions
  • {{ current_user }}: Returns the current user object.
  • {{ reset_password_url }}: Returns the URL with the token for setting the password.
User Attributes
Accessible via {{ current_user }}
Example Usage

Targeted Invite

Template Path: themes/default/mailers/auth/targeted_invite.tmpl This template is used for sending targeted invitations to users.
Available Functions
  • {{ user }}: Returns the targeted user object.
  • {{ team }}: Returns the team name to which the user is being invited.
  • {{ invite_url }}: Returns the URL with the token for setting the password.
User Attributes
Accessible via {{ user }}
Example Usage

Welcome User

Template Paths:
  • themes/default/mailers/welcome_admin.tmpl
  • themes/default/mailers/welcome_dev.tmpl
These templates are used for sending welcome emails to new users, with separate templates for administrators and developers.
Available Objects
  • {{ .user }}: Returns the user who made the request. Refer to the CurrentUser section for accessible attributes and methods.

User Attributes

Accessible via {{ .user }}