本文整理汇总了C#中Template.ParseInternal方法的典型用法代码示例。如果您正苦于以下问题:C# Template.ParseInternal方法的具体用法?C# Template.ParseInternal怎么用?C# Template.ParseInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.ParseInternal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPersistentAssignsSquashInstanceAssigns
public void TestPersistentAssignsSquashInstanceAssigns()
{
Template t = new Template();
Assert.AreEqual("from instance assigns",
t.ParseInternal("{% assign foo = 'from instance assigns' %}{{ foo }}").Render());
t.Assigns["foo"] = "from persistent assigns";
Assert.AreEqual("from persistent assigns", t.ParseInternal("{{ foo }}").Render());
}
示例2: 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));
}
示例3: 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());
}
示例4: TestInstanceAssignsPersistOnSameTemplateObjectBetweenParses
public void TestInstanceAssignsPersistOnSameTemplateObjectBetweenParses()
{
Template t = new Template();
Assert.AreEqual("from instance assigns", t.ParseInternal("{% assign foo = 'from instance assigns' %}{{ foo }}").Render());
Assert.AreEqual("from instance assigns", t.ParseInternal("{{ foo }}").Render());
}
示例5: TestCustomAssignsSquashInstanceAssigns
public void TestCustomAssignsSquashInstanceAssigns()
{
Template t = new Template();
Assert.AreEqual("from instance assigns", t.ParseInternal("{% assign foo = 'from instance assigns' %}{{ foo }}").Render());
Assert.AreEqual("from custom assigns", t.ParseInternal("{{ foo }}").Render(Hash.FromAnonymousObject(new { foo = "from custom assigns" })));
}
示例6: TestCustomAssignsDoNotPersistOnSameTemplate
public void TestCustomAssignsDoNotPersistOnSameTemplate()
{
Template t = new Template();
Assert.AreEqual("from custom assigns", t.ParseInternal("{{ foo }}").Render(Hash.FromAnonymousObject(new { foo = "from custom assigns" })));
Assert.AreEqual("", t.ParseInternal("{{ foo }}").Render());
}