Templates
This is a valid template.
'; // A template function portalOptions.templates.contact = function () { return 'This is, too!
'; }; ``` ## Placeholder Content Templates accept placeholder variables that are automatically replaced with content during the render process. ```js /** * Content * Placeholder variables for content. */ {{mashery.area}} // The name of your Portal as defined in Control Center. {{content.heading}} // The title of the page's H1 element, if one exists. {{content.main}} // The main content for the page. On custom pages and documentation, this is whatever content you've entered in Control Center. On Mashery-generate pages, it's the primary body content. On some pages, this is overridden by a [page-specific label that you can customize](/docs/read/customizing_your_portal/mashery_portal_2_documentation/Labels). {{content.form}} // On pages with forms (sign in, registration, etc.), the form. {{content.secondary}} // Varies by page. On the Documentation pages, it's the navigation sidebar. {{content.logo}} // Your logo, if one is specified. If not, falls back to `{{mashery.area}}`. {{content.navItemsAccount}} // The user account navigation items as a list of linked list elements *without* a parent `- ` or `
- API: ' + (app.api ? app.api : 'None') + ' ' + '
- Key: ' + (app.key ? app.key : 'None') + ' ' + '
- Created: ' + app.created + ' ' + '
- Secret: ' + key.secret + ' ' : ''; template += '
- Key: ' + key.key + ' ' + secret + '
- Status: ' + key.status + ' ' + '
- Created: ' + key.created + ' ' + '
- {{content.applicationLabel}} ' + window.mashery.content.secondary.application + ' ' + '
- {{content.createdLabel}} ' + window.mashery.content.secondary.created + ' ' + (window.mashery.content.secondary.api ? '
- {{content.apiLabel}} ' + window.mashery.content.secondary.api + ' ' : '') + (window.mashery.content.secondary.key ? '
- {{content.keyLabel}} ' + window.mashery.content.secondary.key + ' ' : '') + '
- {{content.applicationLabel}} ' + window.mashery.content.secondary.application + ' ' + '
- {{content.createdLabel}} ' + window.mashery.content.secondary.created + ' ' + (window.mashery.content.secondary.api ? '
- {{content.apiLabel}} ' + window.mashery.content.secondary.api + ' ' : '') + (window.mashery.content.secondary.key ? '
- {{content.keyLabel}} ' + window.mashery.content.secondary.key + ' ' : '') + '
- {{content.applicationLabel}} ' + window.mashery.content.secondary.application + ' ' + '
- {{content.keyLabel}} ' + window.mashery.content.secondary.key + ' ' + (window.mashery.content.secondary.secret ? '
- {{content.secretLabel}} ' + window.mashery.content.secondary.secret + ' ' : '') + '
- {{content.statusLabel}} ' + window.mashery.content.secondary.status + ' ' + '
- {{content.createdLabel}} ' + window.mashery.content.secondary.created + ' ' + '
- {{content.applicationLabel}} ' + window.mashery.content.secondary.application + ' ' + '
- {{content.keyLabel}} ' + window.mashery.content.secondary.key + ' ' + (window.mashery.content.secondary.secret ? '
- {{content.secretLabel}} ' + window.mashery.content.secondary.secret + ' ' : '') + '
- {{content.statusLabel}} ' + window.mashery.content.secondary.status + ' ' + '
- {{content.createdLabel}} ' + window.mashery.content.secondary.created + ' ' + '
- {{content.userWebsite}} ' + window.mashery.content.main.website + ' '; } if (window.mashery.content.main.blog) { template += '
- {{content.userBlog}} ' + window.mashery.content.main.blog + ' '; } template += '
- {{content.userRegistered}} ' + window.mashery.content.main.registered + ' '; template += '
- `.
{{content.navItemsMasheryAccount}} // The mashery account navigation items (change your password, email, etc.) as a list of linked list elements *without* a parent `
- ` or `
- `.
{{content.navItemsPrimary}} // The primary navigation menu items as a list of linked list elements *without* a parent `
- ` or `
- `.
{{content.navItemsSecondary}} // The secondary navigation menu items as a list of linked list elements *without* a parent `
- ` or `
- `.
{{content.navItemsUser}} // The user navigation menu items (sign in, register, logout, etc.) as a list of linked list elements *without* a parent `
- ` or `
- `.
{{content.masheryMade}} // The Mashery Made logo. If you don't include this, it will be automatically injected into the footer.
{{content.terms}} // The account registration Terms of Use.
{{content.privacyPolicy}} // A custom privacy policy or terms of use for your organization, if you'd like to include them with the Mashery Terms of Use.
{{content.searchForm}} // The search form.
{{mashery.title}} // The page title. The H1 content for most pages, or, if unspecified, the Mashery Area name.
{{mashery.username}} // The currently logged in user's username.
/**
* Paths
* Placeholder variables for system URLs.
*/
{{path.apps}} // The My Apps page.
{{path.keys}} // The My Keys page.
{{path.account}} // The My Account page.
{{path.changeEmail}} // The page to change your email.
{{path.changePassword}} // The page to change your password.
{{path.contact}} // The contact page.
{{path.dashboard}} // The Control Center Dashboard.
{{path.docs}} // The documentation page.
{{path.iodocs}} // The IO Docs page.
{{path.logout}} // The logout link.
{{path.lostPassword}} // The page to request a lost password.
{{path.lostUsername}} // The page to request a lost username.
{{path.removeMember}} // The link to trigger a remove account request.
{{path.register}} // The page to register a new account.
{{path.registerResendConfirmation}} // The page to confirm that a registration email was resent.
{{path.removeMembership}} // The page to remove account membership from this Portal.
{{path.search}} // The search results page.
{{path.signin}} // The sign in page.
{{path.viewProfile}} // The current user's profile.
```
In addition to the global placeholders listed above, each template has local placeholder specific to that template or content type.
## The Templates
Default values are shown below.
```js
// Base layout
// The markup structure that all of the content will get loaded into.
// {{layout.navUser}} - The wrapper for the user navigation.
// {{layout.navPrimary}} - The wrapper for the primary navigation.
// {{layout.main}} - The wrapper for the main content area.
// {{layout.footer1}} - The wrapper for the first footer content area.
// {{layout.navSecondary}} - The wrapper for the secondary navigation.
// {{layout.footer2}} - The wrapper for the second footer content area.
portalOptions.templates.layout =
'Skip to content' +
'{{layout.navUser}}' +
'{{layout.navPrimary}}' +
'{{layout.main}}' +
'';
// My Apps
// The page displaying a users registered applications.
// {{content.noApps}} - The content to display when the user has no applications.
portalOptions.templates.accountApps = function () {
var template = '
{{content.heading}}
'; if (Object.keys(mashery.content.main).length > 0) { mashery.content.main.forEach(function (app) { template += '' + app.application + '
' + '- ' +
'
'; if (app.edit) { template += 'Edit This App'; } if (app.delete) { template += 'Delete This App'; } if (app.add) { template += 'Add APIs'; } template += '
'; }); } else { template += '{{content.noApps}}'; } if (mashery.content.secondary) { template += ''; } return '{{content.heading}}
' + ' ' + ' ' + '{{content.main}}' + '{{content.heading}}
' + ' ' + ' ' + '{{content.main}}' + '{{content.heading}}
'; if (Object.keys(mashery.content.main).length > 0 ) { mashery.content.main.forEach(function (plan) { template += '' + plan.name + '
'; if (plan.keys.length > 0) { plan.keys.forEach(function (key) { var secret = key.secret ? '' + key.application + '
' + '- ' +
'
' + 'View Report' + 'Delete This Key' + '
'; }); } else { template += '{{content.noPlanKeys}}
'; if (mashery.content.secondary) { template += 'Get a Key for ' + plan.name + '
'; } } }); } else { template += '{{content.noKeys}}'; if (mashery.content.secondary) { template += ''; } } return '{{content.heading}}
' + ' ' + ' ' + '{{content.subheading}}
' + '{{content.main}}' + '{{content.heading}}
' + ' ' + ' ' + '{{content.main}}' + '{{content.heading}}
' + ' ' + ' ' + '{{content.main}}' + '{{content.heading}}
' + '- ' +
'
{{content.subheading}}
' + '{{content.main}}' + '{{content.heading}}
' + '- ' +
'
{{content.subheading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.blogTitle}}
'; var excerpt = document.createElement('div'); window.mashery.content.main.forEach(function (post) { excerpt.innerHTML = m$.convertMarkdown(post.content); template += '' + '' + post.title + '' + '
' + '' + 'By ' + post.author + ' on ' + '
' + '' + window.mashery.content.main.title + '
' + '' + 'By ' + window.mashery.content.main.author + ' on ' + '
' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}' + '{{content.subheading}}
' + '- {{content.secondary}}
The forum content needs to get created.
{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.terms}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
' + ' ' + '{{content.subheadingAPI}}
' + '- ' +
'
{{content.heading}}
' + '{{content.subheadingAPI}}
' + '- ' +
'
{{content.subheadingConfirm}}
' + '{{content.main}}' + '{{content.form}}'; return '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}
' + '' + '{{content.confirm}}' + '{{content.cancel}}' + '
' + '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}
' + '{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
'; if (window.mashery.content.main.admin) { template += 'View administrative profile for ' + window.mashery.content.main.name + '
'; } template += '{{content.headingUserInfo}}
' + '- ';
if (window.mashery.content.main.website) {
template += '
{{content.headingActivity}}
' + window.mashery.content.main.activity; } return '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.terms}}' + '{{content.heading}}
' + 'We have sent a confirmation email to you at {{content.main}}.
' + 'Please click on the link in that e-mail to confirm your account. If you do not receive an email within the next hour, click here to resend confirmation email.
' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.headingNew}}
' + '{{content.searchForm}}'; } else if (window.mashery.content.main) { template += '{{content.heading}}
' + '{{content.searchForm}}' + '{{content.meta}}
'; window.mashery.content.main.forEach(function (result) { template += '' + result.title + '
' + '' +
result.summary +
'
' +
'' + result.url + '' +
'
{{content.heading}}
' + '{{content.searchForm}}' + '{{content.noResults}}'; } return '{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.heading}}
' + '{{content.main}}' + '{{content.form}}' + 'Docs Navigation
- API Documentation Portal
- IO Docs Definition
- Mashery API Documentation
- Mashery 3.0 API Guide
- Mashery 2.0 API Guide
- OAuth Supporting Methods
- Examples
- JSON RPC
- Authentication
- API Objects
- Fetching Objects
- Query Language
- Creating Objects
- Updating Objects
- Validating Fields
- Deleting Objects
- Applications
- General Object Methods
- Members
- Packages
- Plans
- Package Keys
- Keys
- Developer Classes
- Services
- Roles
- Mashery 2.0 Reporting API Guide
- Event Trigger API
- Differences between Roles and Portal Access Groups
- Managing a Portal Access Group Using Mashery V2 or V3 API
- Mashery Reporting Event Post API Guide
- Tips and Tricks
- Your Portal
- API Traffic Manager
- I/O Docs WSDL requirements