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


C# Template.Render方法代码示例

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


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

示例1: TestConditional_True

 public void TestConditional_True()
 {
     var template = new Template("$if(value)$yes$endif$", '$', '$');
     template.Add("value", true);
     var output = template.Render();
     Assert.AreEqual("yes", output);
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:7,代码来源:TestStringTemplate.cs

示例2: TestDefaultDelimiter

 public void TestDefaultDelimiter()
 {
     var template = new Template("hello <token>.");
     template.Add("token", "world");
     var output = template.Render();
     Assert.AreEqual("hello world.", output);
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:7,代码来源:TestStringTemplate.cs

示例3: TestConditional_NotNull

 public void TestConditional_NotNull()
 {
     var template = new Template("$if(value)$yes$endif$", '$', '$');
     template.Add("value", "Some Object");
     var output = template.Render();
     Assert.AreEqual("yes", output);
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:7,代码来源:TestStringTemplate.cs

示例4: renders_the_template

        public void renders_the_template()
        {
            var theValue = TemplateValue.For("field", "FirstName");
            var theTemplate = new Template(StringToken.FromKeyString("Test", "{field} is required"), theValue);

            theTemplate.Render().ShouldBe("FirstName is required");
        }
开发者ID:RyanHauert,项目名称:fubumvc,代码行数:7,代码来源:TemplateValueTester.cs

示例5: NotificationMessage

        public NotificationMessage(StringToken stringToken, params TemplateValue[] values)
        {
            StringToken = stringToken;

            _template = new Template(stringToken, values);
            _message = new Lazy<string>(() => _template.Render());
        }
开发者ID:RyanHauert,项目名称:fubumvc,代码行数:7,代码来源:NotificationMessage.cs

示例6: GenerateMain

        public static void GenerateMain(string entryType, string entryNamespace, bool inputArgs)
        {
            StreamWriter writer = new StreamWriter(FileWritterManager.WorkingPath + "main.cpp");

            string txt;
            Template template;

            string altTools = Environment.GetEnvironmentVariable("ALTERNATIVE_TOOLS_PATH");

            if(altTools == null)
                altTools = Path.Combine(Environment.CurrentDirectory, (@"..\..\..\Tools").Replace('\\','/'));

            StreamReader sr = new StreamReader((altTools + @"\Templates\Code\main.stg").Replace('\\', '/'));
            txt = sr.ReadToEnd();
            template = new Template(txt);

            StreamReader fs = new StreamReader(Path.Combine(altTools, "Text/notice"));
            string notice = fs.ReadToEnd();

            template.Add("NOTICE", notice);
            template.Add("ENTRY_TYPE", entryType);
            template.Add("ENTRY_NAMESPACE_NEEDED", !String.IsNullOrEmpty(entryNamespace));
            template.Add("ENTRY_NAMESPACE", entryNamespace);
            template.Add("INPUT_ARGS", inputArgs);

            string output = template.Render();

            writer.Write(output);
            writer.Flush();
            writer.Close();

            FileWritterManager.AddSourceFile("main.cpp");
        }
开发者ID:KAW0,项目名称:Alter-Native,代码行数:33,代码来源:MainWritter.cs

示例7: TestAlternateDelimiter

 public void TestAlternateDelimiter()
 {
     var template = new Template("hello ~token~.", '~', '~');
     template.Add("token", "world");
     var output = template.Render();
     Assert.AreEqual("hello world.", output);
 }
开发者ID:rickeygalloway,项目名称:Test,代码行数:7,代码来源:TestStringTemplate.cs

示例8: TestComplicatedExpression

 public void TestComplicatedExpression()
 {
     var templateContent = "${(8+2)*(5+5) - ((2+8)/2)}";
     var template = new Template(templateContent);
     var render = template.Render();
     Assert.AreEqual("95", render);
 }
开发者ID:ks3dev,项目名称:jntemplate,代码行数:7,代码来源:TagsTests.cs

示例9: ExpandMacros

        /// <summary>
        /// Expands the macros in the given string using the variables stored inside
        /// this object. The resulting string will have the macros expanded.
        /// </summary>
        /// <param name="input">The input string.</param>
        /// <returns>The output string with macros expanded.</returns>
        public string ExpandMacros(string input)
        {
            // If we have a null, then just return a null.
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            // We have to repeatedly run through the macros since we have macros
            // that expand into other macros.
            string results = input;

            while (results.IndexOf('{') >= 0)
            {
                // Create a template with all of the variables inside it.
                var template = new Template(results, '{', '}');

                foreach (KeyValuePair<string, string> macro in Substitutions)
                {
                    template.Add(macro.Key, macro.Value);
                }

                // Render out the template to the results.
                results = template.Render();
            }

            // Return the resulting string.
            return results;
        }
开发者ID:dmoonfire,项目名称:author-intrusion-cil,代码行数:35,代码来源:ProjectMacros.cs

示例10: 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

示例11: 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

示例12: TestLambdaIsCalledOnceFromCustomAssignsOverMultipleParsesAndRenders

 public void TestLambdaIsCalledOnceFromCustomAssignsOverMultipleParsesAndRenders()
 {
     Template t = new Template();
     int global = 0;
     Hash assigns = Hash.FromAnonymousObject(new { number = (Proc) (c => ++global) });
     Assert.AreEqual("1", t.ParseInternal("{{number}}").Render(assigns));
     Assert.AreEqual("1", t.ParseInternal("{{number}}").Render(assigns));
     Assert.AreEqual("1", t.Render(assigns));
 }
开发者ID:QMTech,项目名称:dotliquid,代码行数:9,代码来源:TemplateTests.cs

示例13: TestAttr

 public void TestAttr()
 {
     string template = "hi $name$!";
     Template st = new Template(template, '$', '$');
     st.Add("name", "Ter");
     string expected = "hi Ter!";
     string result = st.Render();
     Assert.AreEqual(expected, result);
 }
开发者ID:jamilgeor,项目名称:antlrcs,代码行数:9,代码来源:TestDollarDelimiters.cs

示例14: TestLambdaIsCalledOnceFromPersistentAssignsOverMultipleParsesAndRenders

 public void TestLambdaIsCalledOnceFromPersistentAssignsOverMultipleParsesAndRenders()
 {
     Template t = new Template();
     int global = 0;
     t.Assigns["number"] = (Proc) (c => ++global);
     Assert.AreEqual("1", t.ParseInternal("{{number}}").Render());
     Assert.AreEqual("1", t.ParseInternal("{{number}}").Render());
     Assert.AreEqual("1", t.Render());
 }
开发者ID:kurvenschubser,项目名称:dotliquid,代码行数:9,代码来源:TemplateTests.cs

示例15: TestEarlyEval

 public void TestEarlyEval()
 {
     string template = "<(name)>";
     Template st = new Template(template);
     st.Add("name", "Ter");
     string expected = "Ter";
     string result = st.Render();
     Assert.AreEqual(expected, result);
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:9,代码来源:TestIndirectionAndEarlyEval.cs


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