NVelocity模板引擎如何支持传参数?

xwspider 2008-12-01 02:14:19
NVelocity模板引擎如何支持传参数?
我看到DEDEcms他们的模板都可以 fileid=10 或者 id=10什么的进行传参,NVelocity模板引擎如何传参给C#代码呢?
...全文
167 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
孤独侠客123 2008-12-09
  • 打赏
  • 举报
回复
1.Using a dictionary to pass parameters

#component(MyFirstComponent "%{firstParam='some value',anotherParam='other value'}")



public class MyFirstComponent: ViewComponent
{
public override void Render()
{
object param1 = Context.ComponentParameters["firstParam"];
object param2 = Context.ComponentParameters["anotherParam"];

...
}
}



2.Using a list of key/value pairs
 #component(ComponentName with "name=john" "address=some address")

or
#component(ComponentName with "name=${customer.name}")


You can gain access to the component parameters using the Context.ComponentParameters too
android2008 2008-12-09
  • 打赏
  • 举报
回复
不懂,up
hawaiiboys 2008-12-09
  • 打赏
  • 举报
回复
帮顶下
sxmonsy 2008-12-06
  • 打赏
  • 举报
回复
应该都能吧
林g 2008-12-06
  • 打赏
  • 举报
回复
顶!
enihs 2008-12-02
  • 打赏
  • 举报
回复
可以的 键值对的方式 例子
velocity里面调用c#里面的一个方法 $this.HandleStr("年份",12,$item)

c#里面的方法是这样写的 public string HandleStr(string value, int length, int row){}
leonwan 2008-12-02
  • 打赏
  • 举报
回复
支持

13,345

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET技术前瞻
社区管理员
  • .NET技术前瞻社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧