CodeMash
  • 🚀Backend as a service
  • 🦄Roadmap
  • 🍕Release Notes
  • Installation
    • Managed Service
    • 🏗️AWS-CDK
    • 🏗️Azure
    • 🏗️Docker
    • 🏗️GC
    • 🏗️Terraform
  • dashboard
    • CodeMash Cloud
    • Project
    • Membership
      • Users
      • Roles
      • Policies
      • Triggers
      • Integrations
        • Apple
        • Azure
        • Facebook
        • Google
        • Twitter
      • Settings
    • Database
      • Collections
        • Schema
          • From Template
          • Structure
        • Tabs
        • Triggers
        • Indexes
        • Shared Forms
      • Taxonomies
        • Terms
        • Schema
        • Settings
      • Aggregation
      • Imports
      • Exports
      • Backups
    • Files
      • Integrations
        • CodeMash
        • S3 Bucket
    • Notifications
      • Push
        • Push Templates
        • Push Templates API
        • Push Notifications
        • Push Notifications API
        • Devices
        • Devices API
        • Integrations
          • Firebase
          • One Signal
          • Expo
      • Email
        • Email Templates
        • Emails
        • Integrations
          • AWS SES
          • Twilio Sendgrid
          • Mailgun
      • 🏗️Server events
      • 🏗️Sms
    • Payments
      • Integrations
        • Apple Pay
        • Google Pay
        • Stripe
        • Kevin.
        • Paysera
        • Decta
    • Scheduler
    • Logs & Monitoring
    • Code
      • Functions
        • Function Inputs
        • Function Templates
          • Node.js
          • Python
          • Ruby
          • Java
          • Go
          • .NET Core
      • CodeMash Functions
        • Google Functions
          • Google Calendar
          • Google Gmail
        • Microsoft Functions
          • Microsoft 365 Users
          • Microsoft 365 Calendar
        • Collection Find
        • Collection Update
        • Users Find
        • Image Resize
        • Html To Pdf
        • Word Document
        • Barcode
        • QR Code
        • Send Email
        • Send Notification
        • Email Reminder
        • Notification Reminder
      • Integrations
        • AWS Lambda
        • Google Cloud Functions
        • Azure Functions
  • Other Topics
    • Apple
      • Developer Portal
      • Bundle Identifier
      • Team ID
      • Service ID
      • Key ID
    • Triggers
    • Tokens Binding
      • Project Tokens
      • Initiator Tokens
      • Receiver Tokens
      • Request Tokens
      • Operation based tokens
      • Template Functions
    • Search parameters
      • Paging
      • Filter
      • Sort
      • Projection
    • data-models
    • Errors
  • SDK
    • Node.js
    • TypeScript
    • .NET
    • 🏗️Go Lang
    • 🏗️Flutter
    • 🏗️Swift
    • 🏗️Kotlin
  • CLI
    • 🏗️CodeMash CLI
  • API
    • Get Started
    • Prerequisites
    • How to test?
    • Cors
    • Project
    • Membership
      • Authentication
      • Users
    • Database
      • Collections
        • Aggregate
        • Change Responsibility
        • Count
        • Delete
        • Delete Many
        • Distinct
        • Find
        • Find One
        • Insert
        • Insert Many
        • References
        • Replace
        • Update
        • Update Many
      • Taxonomies
        • Find
    • Files
    • Code
    • Notifications
      • Push
      • Emails
      • Server Events
      • 🏗️Sms
    • Payments
    • Scheduler
    • Logs & Monitoring
Powered by GitBook
On this page
  • Types of tokens
  • Writing tokens in templates
  • Injection specifics

Was this helpful?

Edit on GitHub
  1. Other Topics

Tokens Binding

PreviousTriggersNextProject Tokens

Last updated 4 years ago

Was this helpful?

Tokens are key-value pairs that can be used for static and dynamic data purposes. Mainly you want to use tokens for injecting values into an email or push notification templates. For template parsing, we are using Razor engine which has its specific syntax (for a full syntax overview click ).

Types of tokens

There 4 types of tokens used in CodeMash. All of them are explained more in detail in the following pages.

There are also specific tokens that should be added to your templates to support some of the operations. These tokens can be found on the following page.

Writing tokens in templates

For your tokens to be successfully injected you need to add @Model before each of your token so that it would look something like this:

Welcome to project @Model.Project.Name.

That is because all of your tokens are added under the object Model and symbol @ is needed for Razor engine to understand this as a user variable. Unlike Razor syntax where @ symbol doesn't need to be added at certain times, here it must be added at all times.

Templates can also contain other Razor syntax tools not only variables. The more complex example shown below:

Welcome to project @Model.Project.Name.

@{
   if (@Model.Receiver.User.FirstName == "John")
   {
       <p>Hello John</p>
   }
}

<p style="color: @Model.Colour.Red">Thanks for registering to a project</p>

There are predefined functions to ease the use of tokens.

Injection specifics

When CodeMash injects token values into your templates, it might do so in an unexpected way. The following points try to explain some of that unexpected behavior.

  • If one token is Custom.Token and another token is Custom.Token.Value, the first token will not be injected because the second token makes the first token to become the object without its own value. So in this case, the first token needs to be renamed. For example, it could be Custom.Token.Value1 or Custom.Token1.

  • Types of your basic token values will be automatically adjusted, that means, if your string value can be parsed into integer, bool, float, then their types will be changed. For example, if you pass a token with a value "4" (quotes indicates a string) then in the template it will be of type integer (parsed from a string).

here
Project Tokens
Initiator Tokens
Receiver Tokens
Request Tokens
Operation based tokens
Template Functions