Class MacroProcessor
- Namespace
- CMS.MacroEngine
- Assembly
- CMS.MacroEngine.dll
Class providing general macro processing methods.
public static class MacroProcessor
- Inheritance
-
objectMacroProcessor
Fields
NOT_RESOLVE
Defines a replacement constant for macro processing to not resolve the macro at all
public const string NOT_RESOLVE = "##NOT_RESOLVE##"
Field Value
- string
Methods
BuildMacroParameter(MacroIdentityOption)
Builds macro parameter from identity option.
public static string BuildMacroParameter(MacroIdentityOption identityOption)
Parameters
identityOptionMacroIdentityOptionIdentity option for which to build the parameter.
Returns
- string
Macro parameter string.
BuildMacroParameter(string, string)
Builds the macro parameter.
public static string BuildMacroParameter(string name, string value)
Parameters
namestringParameter name
valuestringParameter value
Returns
- string
ContainsMacro(string)
Returns true if the specified text contains macro.
public static bool ContainsMacro(string inputText)
Parameters
inputTextstringText to check
Returns
- bool
DecodeMacros(string)
HTML decodes macro definitions for given text.
public static string DecodeMacros(string inputText)
Parameters
inputTextstringInput text
Returns
- string
EncodeMacro(string)
Encodes macro to prevent its resolving.
public static string EncodeMacro(string macro)
Parameters
macrostringMacro definition
Returns
- string
EscapeParameterValue(string)
Escapes the parameter value (ensures nested macros within the parameter values are escaped).
public static string EscapeParameterValue(string value)
Parameters
valuestringValue to escape
Returns
- string
GetMacros(string, bool)
Gets the list of macros in the given text.
public static string GetMacros(string originalText, bool onlySimpleMacros = false)
Parameters
originalTextstringText to analyze for macros
onlySimpleMacrosboolIf true, only simple macros are returned
Returns
- string
IsLocalizationMacro(string)
Returns true if given text is in {\(xxx\)} format. Note that this method returns true only if the whole text is localization macro, it is NOT a contains method.
public static bool IsLocalizationMacro(string text)
Parameters
textstringText to check
Returns
- bool
ProcessDataMacros(string, string, OnProcessMacro)
Replaces data macros with given replacement or resolves them if replacement is null.
public static string ProcessDataMacros(string text, string replacement, MacroProcessor.OnProcessMacro processMacro)
Parameters
textstringText where the macros will be replaced/resolved
replacementstringReplacement string
processMacroMacroProcessor.OnProcessMacroCallback to handle the macro resolving
Returns
- string
ProcessMacros(IDataContainer, ObjectTypeInfo, Func<MacroProcessingContext, string, string>, List<string>, bool)
Replaces macros with given replacement or resolves them if replacement is null.
public static bool ProcessMacros(IDataContainer data, ObjectTypeInfo typeInfo, Func<MacroProcessingContext, string, string> lambda, List<string> type = null, bool processOpenExpressions = true)
Parameters
dataIDataContainerObject to process
typeInfoObjectTypeInfoObject type info of processed object.
lambdaFunc<MacroProcessingContext, string, string>Lambda expression called on each macro
typeList<string>Type of the macro to resolve (if null, all types are resolved).
processOpenExpressionsboolIf true, open expressions such as {% if (true) { %} any HTML code {%}%} are processed
Returns
- bool
RemoveDataMacroBrackets(string)
Removes data macro brackets {% %} from given text.
public static string RemoveDataMacroBrackets(string value)
Parameters
valuestringValue to modify
Returns
- string
RemoveLocalizationMacroBrackets(string)
Removes localization macro brackets {$ $} from given text.
public static string RemoveLocalizationMacroBrackets(string value)
Parameters
valuestringValue to modify
Returns
- string
RemoveMacroBrackets(string, out string)
Removes all types macro brackets from given text.
public static string RemoveMacroBrackets(string value, out string type)
Parameters
valuestringValue to modify
typestringType of macro which was removed
Returns
- string
RemoveMacros(string, string)
Removes macros from input text. Macros are replaced by specified replacement.
public static string RemoveMacros(string inputText, string replacement = "")
Parameters
inputTextstringInput text
replacementstringReplacement string
Returns
- string
RemoveParameter(string, string)
Removes parameter with given name from macro expression (expression should be without brackets {%%}).
public static string RemoveParameter(string expression, string name)
Parameters
expressionstringMacro expression without the type brackets
namestringName of the parameter to remove
Returns
- string
RemoveParameter(string, string, out string)
Removes parameter with given name from macro expression (expression should be without brackets {%%}).
public static string RemoveParameter(string expression, string name, out string value)
Parameters
expressionstringMacro expression without the type brackets
namestringName of the parameter to remove
valuestringValue of the removed parameter will be passed here
Returns
- string
RemoveQueryMacroBrackets(string)
Removes query macro brackets {? ?} from given text.
public static string RemoveQueryMacroBrackets(string value)
Parameters
valuestringValue to modify
Returns
- string
UnescapeParameterValue(string)
Un escapes the parameter value.
public static string UnescapeParameterValue(string value)
Parameters
valuestringValue to unescape
Returns
- string