当前位置: 首页>>代码示例>>C#>>正文


C# UmbracoHelper.RenderMacro方法代码示例

本文整理汇总了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;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:25,代码来源:HtmlStringDataTypeModel.cs

示例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()));
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:22,代码来源:RteMacroRenderingPropertyEditorValueConverter.cs


注:本文中的UmbracoHelper.RenderMacro方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。