本文整理汇总了C#中UmbracoHelper.RenderMacro方法的典型用法代码示例。如果您正苦于以下问题:C# UmbracoHelper.RenderMacro方法的具体用法?C# UmbracoHelper.RenderMacro怎么用?C# UmbracoHelper.RenderMacro使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UmbracoHelper
的用法示例。
在下文中一共展示了UmbracoHelper.RenderMacro方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public bool Init(int CurrentNodeId, string PropertyData, out object instance)
{
//we're going to send the string through the macro parser and create the output string.
if (UmbracoContext.Current != null)
{
var sb = new StringBuilder();
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
MacroTagParser.ParseMacros(
PropertyData,
//callback for when text block is found
textBlock => sb.Append(textBlock),
//callback for when macro syntax is found
(macroAlias, macroAttributes) => sb.Append(umbracoHelper.RenderMacro(
macroAlias,
//needs to be explicitly casted to Dictionary<string, object>
macroAttributes.ConvertTo(x => (string)x, x => (object)x)).ToString()));
instance = new HtmlString(sb.ToString());
}
else
{
//we have no umbraco context, so best we can do is convert to html string
instance = new HtmlString(PropertyData);
}
return true;
}
示例2: ConvertPropertyValue
/// <summary>
/// Return IHtmlString so devs doesn't need to decode html
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public override Attempt<object> ConvertPropertyValue(object value)
{
//we're going to send the string through the macro parser and create the output string.
var sb = new StringBuilder();
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
MacroTagParser.ParseMacros(
value.ToString(),
//callback for when text block is found
textBlock => sb.Append(textBlock),
//callback for when macro syntax is found
(macroAlias, macroAttributes) => sb.Append(umbracoHelper.RenderMacro(
macroAlias,
//needs to be explicitly casted to Dictionary<string, object>
macroAttributes.ConvertTo(x => (string)x, x => (object)x)).ToString()));
return new Attempt<object>(true, new HtmlString(sb.ToString()));
}