AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Macro expressions
  3. Resolving macros using the API

Resolving macros using the API


Was this page helpful?

Send us feedback Go back to top

Related pages

  • Extending the macro engine
  • Macro syntax
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

If you need to process macro expressions inside text values in your custom code, use the MacroResolver.Resolve method. Specify the string where you want to resolve macros as the method's input parameter.

For example:

C#
using CMS.MacroEngine;

...

// Resolves macros in the specified string using a new instance of the global resolver
string resolvedTextGlobal = MacroResolver.Resolve("The current user is: {% CurrentUser.UserName %}");

The method evaluates the macros using a new instance of the global resolver and automatically ensures thread-safe processing.

Macro resolvers are system components that provide the processing of macros. The resolvers are organized in a hierarchy that allows child resolvers to inherit all macro options from the parent. The global resolver is the parent of all other resolvers in the system.

Resolving macros on the live site

Certain macros that are only intended for the Xperience administration interface do not work when resolving macros from the code of the live site application. For example, macros that return the HTML code of font icons used in the administration interface. Such macros are only available within the code libraries of the administration application.

Resolving localization macros

If you only need to resolve localization macros in text, call the CMS.Helpers.ResHelper.LocalizeString method.

C#
using CMS.Helpers;

...

// Resolves localization macros in text
string localizedResult = ResHelper.LocalizeString("{$general.actiondenied$}");