[英]How does umbraco mix XSLT with C# code
Take a look at this code: 看一下这段代码:
<ul>
<xsl:for-each select="$currentPage/node">
<li><a>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl(current()/@id)"/>
</xsl:attribute>
<xsl:value-of select="current()/@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
As you can see there are umbraco commands within the xslt. 如您所见,xslt中包含umbraco命令。 How exactly is this done?
这到底是怎么做的? How can I put my own C# commands in my xslt?
如何在xslt中放入自己的C#命令?
Create a class with public static methods. 使用公共静态方法创建一个类。 Then register your assembly in the XsltExtensions.config file in the config directory.
然后在config目录的XsltExtensions.config文件中注册程序集。
There is example configuration in the file. 该文件中有示例配置。
There are a number of approaches for injecting some custom logic. 有很多方法可以注入一些自定义逻辑。 Check it out - http://msdn.microsoft.com/en-us/magazine/cc302079.aspx
签出-http://msdn.microsoft.com/en-us/magazine/cc302079.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.