Changed the Template title syntax requirements.

This change makes it possible to use "complex" shape names (e.g. "Email__Wrapper"). Before this change, the shape file name syntax was required (e.g. "Email-Wrapper").
However, such shapes would not be found when using the {Shape.Execute} token when using the other syntax (e.g. "Email__Wrapper"), since TemplateShapeDisplayEvent simply register the shapes by specified title without first translating the file based syntax to code based syntax.
This commit is contained in:
Sipke Schoorstra
2014-05-20 20:04:19 +02:00
parent 45392f60de
commit 6e49ad2ce2

View File

@@ -70,13 +70,13 @@ namespace Orchard.Templates.Drivers {
return false;
var name = titleViewModel.Title;
if (!string.IsNullOrWhiteSpace(name) &&
if (!String.IsNullOrWhiteSpace(name) &&
name[0].IsLetter() &&
name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '.' || c == '-')) {
name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '_')) {
return true;
}
updater.AddModelError("Title", T("{0} names can only contain alphanumerical, dot (.) or dash (-) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName));
updater.AddModelError("Title", T("{0} names can only contain alphanumerical or underscore (_) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName));
return false;
}