コード例 #1
0
ファイル: Generator.cs プロジェクト: davidwhitney/stasis
        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);
        }