public DataFile RenderDataContent(DataFile dataFile) { RenderingEngine engine; if (this.Transaction.Engines.TryGetValue(dataFile.Extension, out engine)) { var data = new DynamicRenderData(dataFile, this.Transaction.Site); dataFile.Content = engine.Render(dataFile, dataFile.SourceContent, data); } return dataFile; }
private async Task<DataFile> LoadLayoutAsync(string path) { var parser = new ParseDocumentCommand(path); await parser.ExecuteAsync(); var metadataDate = parser.Date; if (this.AdditionalMetadataForFiles != null) { var rootPath = Path.GetDirectoryName(this.DataPath.TrimEnd('\\')); var relativePath = path.Substring(rootPath.Length + 1); foreach (var additionalMetadataConfig in this.AdditionalMetadataForFiles) { if (additionalMetadataConfig.Match.IsMatch(relativePath)) { parser.Metadata.AssignFrom(path, additionalMetadataConfig.Metadata); } } } var disableDateFromFileName = parser.Metadata.GetAndRemove("DisableDateFromFileName", false); // If the parser metadata didn't specify the date, try to use a date from the filename. // if (!disableDateFromFileName && !metadataDate.HasValue) { var fileName = Path.GetFileName(path); var match = DateFromFileName.Match(fileName); if (match.Success) { var year = Convert.ToInt32(match.Groups[1].Value, 10); var month = Convert.ToInt32(match.Groups[2].Value, 10); var day = Convert.ToInt32(match.Groups[3].Value, 10); var hour = match.Groups[4].Success ? Convert.ToInt32(match.Groups[4].Value, 10) : 0; var minute = match.Groups[5].Success ? Convert.ToInt32(match.Groups[5].Value, 10) : 0; var second = match.Groups[6].Success ? Convert.ToInt32(match.Groups[6].Value, 10) : 0; metadataDate = new DateTime(year, month, day, hour, minute, second); } } var dataFile = new DataFile(path, this.DataPath, parser.Content, parser.Metadata, parser.Queries); if (metadataDate.HasValue) { dataFile.SetTimes(metadataDate.Value); } return dataFile; }