Beispiel #1
0
        private void ProcessContentItem(RawItem rawItem, ContentRegistration registration)
        {
            var converter = ItemConverters.FirstOrDefault(x => x.Supports(rawItem.ContentType));

            if (converter == null)
            {
                CopyUnconvertableFile(rawItem, registration);
                return;
            }

            var template = registration.DataSource is IFindTemplates templateSourcing
                ? templateSourcing.SelectTemplate(rawItem, SupportedTemplateEngines)
                : registration.TemplateFinder.SelectTemplate(rawItem, SupportedTemplateEngines);

            var templateEngine = SupportedTemplateEngines.TemplateEngineForTemplate(template);

            var item = converter.ConvertToItem(rawItem.Content);

            item.SourceKey = rawItem.SourceKey;
            var contentProcessingResult = templateEngine.Process(item, template);

            var outputPath     = ProcessPath(contentProcessingResult.OutputName);
            var fullOutputPath = Path.Combine(registration.OutputPath, outputPath);

            Output.Save(fullOutputPath, contentProcessingResult);
        }
Beispiel #2
0
        public Generator()
        {
            ItemConverters.Add(new RazorItemConverter());
            ItemConverters.Add(new MarkdownItemConverter());

            SupportedTemplateEngines.Add(new NoTemplateEngine());
            SupportedTemplateEngines.Add(new RazorTemplateEngine());
            SupportedTemplateEngines.Add(new MustacheTemplateEngine());
        }