Merge remote-tracking branch 'original-master/master'
# Conflicts: # mustache-sharp.test/FormatCompilerTester.cs
This commit is contained in:
commit
98b0c501e2
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ../mustache-sharp.sln /p:Configuration=Release
|
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ../mustache-sharp.sln /p:Configuration=Release
|
||||||
nuget pack ../mustache-sharp/mustache-sharp.csproj -Properties Configuration=Release
|
nuget pack ../mustache-sharp/mustache-sharp.csproj -Properties Configuration=Release
|
||||||
nuget push *.nupkg
|
nuget push *.nupkg -Source https://www.nuget.org/api/v2/package
|
||||||
del *.nupkg
|
del *.nupkg
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace Mustache.Test
|
namespace Mustache.Test
|
||||||
|
@ -1690,60 +1691,11 @@ Odd
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ValueIntemplateTests
|
#region Custom Tags
|
||||||
[TestMethod]
|
|
||||||
public void TestCompile_CanUseStringValueInEquals() {
|
|
||||||
FormatCompiler compiler = new FormatCompiler();
|
|
||||||
const string format = @"{{#eq Value _Yesterday}}Yes!{{/eq}}";
|
|
||||||
Generator generator = compiler.Compile(format);
|
|
||||||
|
|
||||||
string actual = generator.Render(new { Value = "Yesterday" });
|
|
||||||
string expected = "Yes!";
|
|
||||||
Assert.AreEqual(expected, actual, "Value field didn't work");
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestCompile_CanUseNumericValueInEquals() {
|
public void TestCompile_NestedContext_ConsolidatesWriter()
|
||||||
FormatCompiler compiler = new FormatCompiler();
|
{
|
||||||
const string format = @"{{#eq Value _123.3231}}Yes!{{/eq}}";
|
|
||||||
Generator generator = compiler.Compile(format);
|
|
||||||
|
|
||||||
|
|
||||||
string actual = generator.Render(new { Value = "123.3231" });
|
|
||||||
string expected = "Yes!";
|
|
||||||
Assert.AreEqual(expected, actual, "Value field didn't work");
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestCompile_NonEqualNumericValue() {
|
|
||||||
FormatCompiler compiler = new FormatCompiler();
|
|
||||||
const string format = @"{{#eq Value _123.3232}}Yes!{{/eq}}";
|
|
||||||
Generator generator = compiler.Compile(format);
|
|
||||||
|
|
||||||
|
|
||||||
string actual = generator.Render(new { Value = "123.3231" });
|
|
||||||
string expected = "";
|
|
||||||
Assert.AreEqual(expected, actual, "Value field didn't work");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region UrlDecodeEncode
|
|
||||||
[TestMethod]
|
|
||||||
public void TestCompile_UrlEncode() {
|
|
||||||
FormatCompiler compiler = new FormatCompiler();
|
|
||||||
compiler.RegisterTag(new UrlEncodeTagDefinition(), true);
|
|
||||||
const string format = @"{{#urlencode}}https://google.com{{/urlencode}}";
|
|
||||||
Generator generator = compiler.Compile(format);
|
|
||||||
|
|
||||||
string actual = generator.Render(new { });
|
|
||||||
string expected = "https%3a%2f%2fgoogle.com";
|
|
||||||
Assert.AreEqual(expected, actual, "Value field didn't work");
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestCompile_UrlEncodeVariableText() {
|
|
||||||
FormatCompiler compiler = new FormatCompiler();
|
FormatCompiler compiler = new FormatCompiler();
|
||||||
compiler.RegisterTag(new UrlEncodeTagDefinition(), true);
|
compiler.RegisterTag(new UrlEncodeTagDefinition(), true);
|
||||||
|
|
||||||
|
@ -1751,24 +1703,39 @@ Odd
|
||||||
Generator generator = compiler.Compile(format);
|
Generator generator = compiler.Compile(format);
|
||||||
|
|
||||||
string actual = generator.Render(new { url = "https://google.com" });
|
string actual = generator.Render(new { url = "https://google.com" });
|
||||||
string expected = "https%3a%2f%2fgoogle.com";
|
string expected = HttpUtility.UrlEncode("https://google.com");
|
||||||
Assert.AreEqual(expected, actual, "Value field didn't work");
|
Assert.AreEqual(expected, actual, "Value field didn't work");
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
public class UrlEncodeTagDefinition : ContentTagDefinition
|
||||||
public void TestCompile_UrlDecode() {
|
{
|
||||||
FormatCompiler compiler = new FormatCompiler();
|
public UrlEncodeTagDefinition()
|
||||||
|
: base("urlencode")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const string format = @"{{#urldecode}}https%3a%2f%2fgoogle.com{{/urldecode}}";
|
public override IEnumerable<NestedContext> GetChildContext(TextWriter writer, Scope keyScope, Dictionary<string, object> arguments, Scope contextScope)
|
||||||
Generator generator = compiler.Compile(format);
|
{
|
||||||
|
NestedContext context = new NestedContext()
|
||||||
|
{
|
||||||
|
KeyScope = keyScope,
|
||||||
|
Writer = new StringWriter(),
|
||||||
|
WriterNeedsConsidated = true,
|
||||||
|
};
|
||||||
|
yield return context;
|
||||||
|
}
|
||||||
|
|
||||||
string actual = generator.Render(new { });
|
public override IEnumerable<TagParameter> GetChildContextParameters()
|
||||||
string expected = "https://google.com";
|
{
|
||||||
Assert.AreEqual(expected, actual, "Value field didn't work");
|
return new TagParameter[] { new TagParameter("collection") };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ConsolidateWriter(TextWriter writer, Dictionary<string, object> arguments)
|
||||||
|
{
|
||||||
|
return HttpUtility.UrlEncode(writer.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||||
|
|
|
@ -81,10 +81,10 @@ namespace Mustache
|
||||||
foreach (IGenerator generator in generators)
|
foreach (IGenerator generator in generators)
|
||||||
{
|
{
|
||||||
generator.GetText(context.Writer ?? writer, context.KeyScope ?? keyScope, context.ContextScope, postProcessor);
|
generator.GetText(context.Writer ?? writer, context.KeyScope ?? keyScope, context.ContextScope, postProcessor);
|
||||||
if (context.WriterNeedsConsidated)
|
}
|
||||||
{
|
if (context.WriterNeedsConsidated)
|
||||||
writer.Write(_definition.ConsolidateWriter(context.Writer ?? writer, arguments));
|
{
|
||||||
}
|
writer.Write(_definition.ConsolidateWriter(context.Writer ?? writer, arguments));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,6 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: Guid("e5a4263d-d450-4d85-a4d5-44c0a2822668")]
|
[assembly: Guid("e5a4263d-d450-4d85-a4d5-44c0a2822668")]
|
||||||
[assembly: AssemblyVersion("0.2.9.0")]
|
[assembly: AssemblyVersion("0.2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("0.2.9.0")]
|
[assembly: AssemblyFileVersion("0.2.10.0")]
|
||||||
[assembly: InternalsVisibleTo("mustache-sharp.test,PublicKey=0024000004800000940000000602000000240000525341310004000001000100755df5a2b24c568812aae0eb194d08a4e3cba960673bcc07a7d446acf52f3f56ae2155b37b8d547bc5d8c562823bd592d1312bef9ad4740a8bb503d0095c31419f9d190882a2fa46090412bf15b13ca0057ba533c85a853333132ec8b70cf19655ef961b06d1c3fc35b3f68680420562be741456cb7a18bd5ab0fa779f8d47b1")]
|
[assembly: InternalsVisibleTo("mustache-sharp.test,PublicKey=0024000004800000940000000602000000240000525341310004000001000100755df5a2b24c568812aae0eb194d08a4e3cba960673bcc07a7d446acf52f3f56ae2155b37b8d547bc5d8c562823bd592d1312bef9ad4740a8bb503d0095c31419f9d190882a2fa46090412bf15b13ca0057ba533c85a853333132ec8b70cf19655ef961b06d1c3fc35b3f68680420562be741456cb7a18bd5ab0fa779f8d47b1")]
|
Loading…
Reference in New Issue