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


C# Template.Set方法代码示例

本文整理汇总了C#中Template.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Template.Set方法的具体用法?C# Template.Set怎么用?C# Template.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Template的用法示例。


在下文中一共展示了Template.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestUnknownVariablesAreIgnored

 public void TestUnknownVariablesAreIgnored()
 {
     Template template = new Template("Hello, ${name}");
     template.Set("unknown", "Hi");
     template.Set("name", "Tom");
     Assert.AreEqual("Hello, Tom", template.Evaluate());
 }
开发者ID:doriath,项目名称:TddPresentation,代码行数:7,代码来源:TemplateTests.cs

示例2: VariablesAreProcessedOnce

 public void VariablesAreProcessedOnce()
 {
     Template template = new Template("${one}, ${two}, ${three}");
     template.Set("one", "${one}");
     template.Set("two", "${two}");
     template.Set("three", "${three}");
     Assert.AreEqual("${one}, ${two}, ${three}", template.Evaluate());
 }
开发者ID:doriath,项目名称:TddPresentation,代码行数:8,代码来源:TemplateTests.cs

示例3: TestMultipleVariables

 public void TestMultipleVariables()
 {
     Template template = new Template("${one}, ${two}, ${three}");
     template.Set("one", "1");
     template.Set("two", "2");
     template.Set("three", "3");
     Assert.AreEqual("1, 2, 3", template.Evaluate());
 }
开发者ID:doriath,项目名称:TddPresentation,代码行数:8,代码来源:TemplateTests.cs

示例4: TestClassFunction

 public void TestClassFunction()
 {
     var templateContent = "$fun.Test(\"字符串\",1,true)";
     var template = new Template(templateContent);
     template.Set("fun", new TemplateMethod());
     var render = template.Render();
     Assert.AreEqual("您输入的参数是有:字符串 1 True ", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:8,代码来源:TagsTests.cs

示例5: TestComent

 public void TestComent()
 {
     var templateContent = "你好,$*使用简写符加星号可对代码注释*$欢迎使用";
     var template = new Template(templateContent);
     template.Set("name", "jntemplate");
     var render = template.Render();
     Assert.AreEqual("你好,欢迎使用", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:8,代码来源:TagsTests.cs

示例6: Constructor

        public void Constructor()
        {
            string message = "参考用";
            var templateContent = "$message";
            var template = new Template(templateContent);
            template.Set("message", message);
            var render = template.Render();

            Assert.Equal("参考用", render);
        }
开发者ID:jiniannet,项目名称:jntemplate,代码行数:10,代码来源:TagsTests.cs

示例7: setDbConfig

        public void setDbConfig()
        {
            String dbType = ctx.Post( "dbType" );
            String dbAddress = ctx.Post( "dbAddress" );
            String dbName = ctx.Post( "dbName" );
            String user = ctx.Post( "user" );
            String pwd = ctx.Post( "pwd" );

            String connectionString = createConnectionString( dbType, dbAddress, dbName, user, pwd );

            String strConfig = getConfigTemplate();
            Template t = new Template();
            t.InitContent( strConfig );
            t.Set( "connectionString", connectionString );
            t.Set( "dbType", dbType );

            String fileName = "/config/orm_test.config";
            String filePath = strUtil.Join( cfgHelper.FrameworkRoot, fileName );
            String dataPath = PathHelper.Map( filePath );
            file.Write( dataPath, t.ToString() );

            echoAjaxOk();
        }
开发者ID:ningboliuwei,项目名称:wojilu,代码行数:23,代码来源:InstallerController.cs

示例8: TestIndexValue2

 public void TestIndexValue2()
 {
     var templateContent = "$data.name";//索引也可以和属性一样取值,不过推荐用get_Item,且如果索引是数字时,请尽量使用$data.get_Item(index)
     var template = new Template(templateContent);
     var dic = new System.Collections.Generic.Dictionary<string, string>();
     dic["name"] = "你好!jntemplate";
     dic["age"] = "1";
     template.Set("data", dic);
     var render = template.Render();
     Assert.AreEqual("你好!jntemplate", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:11,代码来源:TagsTests.cs

示例9: testCode

        public void testCode()
        {
            string html = @"

            <%@ Page Language=""C#"" %>

            <%@ Import Namespace=""wojilu"" %>
            <%@ Import Namespace=""System.Collections.Generic"" %>
            <%@   Import    Namespace="" wojilu.Test.Orm.Entities ""   %>

            <%
            html.show( ""这是第一行"" );
            html.showLine( ""这是第2行"" );
            html.show( ""这是第3行"" );
            html.showLine( html.encode( ""<script>"" ) );
            List<TVPost> posts = v.data(""post"") as List<TVPost>;
            TVPage p = v.data(""p"") as TVPage;
            %>
            <div>文章列表:</div>
            <div>页面信息:#{p.Info},审核:#{p.User.Name}</div>
            <div>页面信息(此行必须先强类型转换):<%=p.Info%>,审核:<%=p.User.Name %></div>

            <script runat=""server"">
            public String getTitle( String title, int count ) {
            return strUtil.CutString( title, count )+""--ztitle"";
            }
            </script>

            <% if( posts.Count==0 ) { %>
            <div>没有数据#{msg}</div>
            <% } else {%>
            <div>数据总共 <%= posts.Count %> 条。#{tip}</div>

            <% for( int i=0;i<posts.Count;i++ ) {%>
            <div>编号:<%=i%>, 标题:<%= getTitle(posts[i].Title,5) %>,作者:<%= posts[i].User.Name %></div>
            <%}%>

            <%}%>
            <div>---------传统的循环标记-----------</div>
            <!-- BEGIN list -->
            <div>没有数据#{x.Title}</div>
            <!-- END list -->

            <div>---------调用ORM-----------</div>
            <%
            List<TArticle> articles = db.find<TArticle>( """" ).list();
            %>
            <% for( int i=0;i<articles.Count;i++ ) { %>
            <div>编号:<%=i%>, 博客:<%= articles[i].Title %>,作者:<%= articles[i].Member.Name %></div>
            <%}%>
            ";
            TVUser u1 = new TVUser { Name = "孙中山1" };
            TVUser u2 = new TVUser { Name = "袁世凯2" };

            TVPage p = new TVPage { Info = "页面info", User = u2 };

            List<TVPost> list = new List<TVPost> {
                new TVPost { Title = "标题111", User=u1 },
                new TVPost { Title = "标题222", User=u2 }
            };

            wojilu.Web.Template tpl = new Template().InitContent( html ) as Template;

            //tpl.Set( "post", list ); // 这种是错误的
            tpl.Bind( "post", list ); // 绑定对象,必须使用bind
            tpl.Bind( "p", p );
            tpl.Set( "msg", "--" );
            tpl.Set( "postId", 8 );
            tpl.Set( "tip", "{这是动态提示}" );

            tpl.BindList( "list", "x", list );

            ITemplateResult x = tpl.Compile();

            Console.WriteLine( x.GetResult() );
            Console.ReadLine();
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:77,代码来源:TemplateNew.cs

示例10: TestDelegateFunction

        public void TestDelegateFunction()
        {
            var templateContent = "$test(\"字符串\",1,true)";
            var template = new Template(templateContent);
            template.Set("test", new JinianNet.JNTemplate.FuncHandler(args =>
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("您输入的参数是有:");
                foreach (var node in args)
                {
                    sb.Append(node);
                    sb.Append(" ");
                }
                return sb.ToString();
            }));

            var render = template.Render();

            Assert.AreEqual("您输入的参数是有:字符串 1 True ", render);
        }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:20,代码来源:TagsTests.cs

示例11: TestReference

 public void TestReference()
 {
     var templateContent = "$date.Year.ToString().Length";
     var template = new Template(templateContent);
     template.Set("date", DateTime.Now);
     var render = template.Render();
     Assert.AreEqual("4", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:8,代码来源:TagsTests.cs

示例12: TestForeach

 public void TestForeach()
 {
     var templateContent = "$foreach(i in list)$i$end";
     var template = new Template(templateContent);
     template.Set("list", new int[] { 7, 0, 2, 0, 6 });
     var render = template.Render();
     Assert.AreEqual("70206", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:8,代码来源:TagsTests.cs

示例13: TestOneVariable

 public void TestOneVariable(string name, string evaluated)
 {
     Template template = new Template("Hello, ${name}");
     template.Set("name", name);
     Assert.AreEqual(evaluated, template.Evaluate());
 }
开发者ID:doriath,项目名称:TddPresentation,代码行数:6,代码来源:TemplateTests.cs

示例14: TestDifferentTemplate

 public void TestDifferentTemplate()
 {
     Template template = new Template("Hi, ${name}");
     template.Set("name", "Tom");
     Assert.AreEqual("Hi, Tom", template.Evaluate());
 }
开发者ID:doriath,项目名称:TddPresentation,代码行数:6,代码来源:TemplateTests.cs

示例15: TestInclub

 public void TestInclub()
 {
     var templateContent = "$include(\"include/header.txt\")";
     var template = new Template(templateContent);
     template.Set("name", "jntemplate");
     template.Context.CurrentPath = new System.IO.DirectoryInfo(System.Environment.CurrentDirectory).Parent.Parent.FullName + System.IO.Path.DirectorySeparatorChar.ToString() + "templets"+ System.IO.Path.DirectorySeparatorChar.ToString() + "default";
     var render = template.Render();
     Assert.Equal("你好,$name", render);
 }
开发者ID:jiniannet,项目名称:jntemplate,代码行数:9,代码来源:TagsTests.cs


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