Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FormatCompiler.cs #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions mustache-sharp/FormatCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,26 @@ public sealed class FormatCompiler
private readonly Dictionary<string, TagDefinition> _tagLookup;
private readonly Dictionary<string, Regex> _regexLookup;
private readonly MasterTagDefinition _masterDefinition;
private readonly string _startTag;
private readonly string _endTag;


/// <summary>
/// Initializes a new instance of a FormatCompiler.
/// </summary>
public FormatCompiler()
: this("{{", "}}")
{

}
/// <summary>
/// Initializes a new instance of a FormatCompiler.
/// </summary>
public FormatCompiler(string startTag, string endTag)
{
_startTag = startTag;
_endTag = endTag;

_tagLookup = new Dictionary<string, TagDefinition>();
_regexLookup = new Dictionary<string, Regex>();
_masterDefinition = new MasterTagDefinition();
Expand Down Expand Up @@ -129,7 +143,7 @@ private Regex prepareRegex(TagDefinition definition)
matches.Add(getTagRegex(childDefinition));
}
matches.Add(getUnknownTagRegex());
string match = "{{(" + String.Join("|", matches) + ")}}";
string match = _startTag + "(" + String.Join("|", matches) + ")" + _endTag;
regex = new Regex(match);
_regexLookup.Add(definition.Name, regex);
}
Expand Down Expand Up @@ -325,7 +339,7 @@ private ArgumentCollection getArguments(TagDefinition definition, Match match, L
string value = null;
if (pair.Capture != null)
{
value = pair.Capture.Value;
value = pair.Capture.Value;
}
else if (pair.Parameter.IsRequired)
{
Expand Down