Skip to content

Commit

Permalink
path to generate catalog from catalog obj not uri
Browse files Browse the repository at this point in the history
  • Loading branch information
wynged committed Nov 8, 2023
1 parent 7d6ba74 commit a661fd1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Elements.CodeGeneration/src/CatalogGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,25 @@ public static string CatalogTemplatePath
/// <param name="useReferenceOrientation">Should ContentElements be reoriented to match the rotation they had when they were exported?</param>
public static void FromUri(string uri, string saveDirectory, bool useReferenceOrientation = false)
{
Template.RegisterSafeType(typeof(ContentCatalog), new[] { "Name", "Content", "ReferenceConfiguration" });
Template.RegisterSafeType(typeof(ContentElement), GetContentElementToRender);
Template.RegisterSafeType(typeof(ElementInstance), GetElementInstanceToRender);
DotLiquid.Template.RegisterFilter(typeof(HyparFilters));

var json = GetContentsOfUri(uri);
ContentCatalog catalog = ContentCatalog.FromJson(json);

// TODO useReferenceOrientation may have fallen out of use entirely. Consider removing this optional flag.
if (useReferenceOrientation)
{
catalog.UseReferenceOrientation();
}

GenerateCatalogClass(catalog, saveDirectory);
}

public static void GenerateCatalogClass(ContentCatalog catalog, string saveDirectory)
{
Template.RegisterSafeType(typeof(ContentCatalog), new[] { "Name", "Content", "ReferenceConfiguration" });
Template.RegisterSafeType(typeof(ContentElement), GetContentElementToRender);
Template.RegisterSafeType(typeof(ElementInstance), GetElementInstanceToRender);
DotLiquid.Template.RegisterFilter(typeof(HyparFilters));
catalog = DeduplicateContentNames(catalog);

var templateText = File.ReadAllText(CatalogTemplatePath);
Expand Down

0 comments on commit a661fd1

Please sign in to comment.