private void ValidateTemplateMarkup(Template template, IEnumerable <TemplateErrorSuppression> errorSuppressions) { var references = template.Steps.SelectMany(s => s.Inputs.Select(i => { var inputId = s.Id; if (!string.IsNullOrEmpty(i.Key)) { inputId += $".{i.Key}"; } if (i.Type == TemplateStepInputType.Text) { return(ReferenceDefinition.String(inputId)); } else if (i.Type == TemplateStepInputType.Checkbox) { return(ReferenceDefinition.Boolean(inputId)); } else if (i.Type == TemplateStepInputType.Radio) { var values = DynamicUtility.Unwrap(() => (IEnumerable <dynamic>)i.TypeData) .Select(d => DynamicUtility.Unwrap <string>(() => d.Value)); return(ReferenceDefinition.StringFrom(inputId, values)); } else { throw new Exception($"Unknown {nameof(TemplateStepInputType)}"); } })); _templateMarkupValidator.Validate(template.Markup, template.MarkupVersion, references, errorSuppressions); }
public Formatter Parse() { var f = _locatorFactory.CloneForTagLib(_lib); if (_initialLocator == null) { _initialLocator = f.GetNewLocator(); } var formatter = new InternalFormatter(new TagLibParserFactory(new TagLibForParsing(_lib), _expressionLib, f, _tagValidator), _expressionLib, _template, _allowTags, _initialLocator); try { formatter.Parse(); CreateTemplateProcessorFor(_lib).Process(formatter.ParsedTemplate); if (_templateValidator != null) { _templateValidator.Validate(formatter.ParsedTemplate); } CreateTemplateValidatorFor(_lib).Validate(formatter.ParsedTemplate); } finally { _templateParsed = formatter.ParsedTemplate; } return(this); }