Give more details for unknown tags

This commit is contained in:
Travis Parks 2013-07-18 12:04:12 -04:00
parent 4a00204bda
commit 3795a77354
6 changed files with 167 additions and 150 deletions

View File

@ -1096,5 +1096,20 @@ Your order total was: $7.50";
} }
#endregion #endregion
#region Unknown Tags
/// <summary>
/// If an unknown tag is encountered, an exception should be thrown.
/// </summary>
[TestMethod]
[ExpectedException(typeof(FormatException))]
public void TestCompile_UnknownTag()
{
FormatCompiler compiler = new FormatCompiler();
compiler.Compile("{{#split Names}}");
}
#endregion
} }
} }

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("0.1.0.0")] [assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -260,7 +260,9 @@ namespace Mustache
} }
else if (match.Groups["unknown"].Success) else if (match.Groups["unknown"].Success)
{ {
throw new FormatException(Resources.UnknownTag); string tagName = match.Value;
string message = String.Format(Resources.UnknownTag, tagName);
throw new FormatException(message);
} }
} }
return formatIndex; return formatIndex;

View File

@ -34,6 +34,6 @@ using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")] [assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: InternalsVisibleTo("mustache-sharp.test")] [assembly: InternalsVisibleTo("mustache-sharp.test")]

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.296 // Runtime Version:4.0.30319.18052
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -115,7 +115,7 @@ namespace Mustache.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Encountered an unknown tag. It was either not registered or exists in a different context.. /// Looks up a localized string similar to Encountered an unknown tag: {0}. It was either not registered or exists in a different context..
/// </summary> /// </summary>
internal static string UnknownTag { internal static string UnknownTag {
get { get {

View File

@ -136,7 +136,7 @@
<value>Expected a matching {0} tag but none was found.</value> <value>Expected a matching {0} tag but none was found.</value>
</data> </data>
<data name="UnknownTag" xml:space="preserve"> <data name="UnknownTag" xml:space="preserve">
<value>Encountered an unknown tag. It was either not registered or exists in a different context.</value> <value>Encountered an unknown tag: {0}. It was either not registered or exists in a different context.</value>
</data> </data>
<data name="WrongNumberOfArguments" xml:space="preserve"> <data name="WrongNumberOfArguments" xml:space="preserve">
<value>The wrong number of arguments were passed to an {0} tag.</value> <value>The wrong number of arguments were passed to an {0} tag.</value>