FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

Default Namespaces for RazorLight

Open rburnham52 opened this issue 5 years ago • 3 comments

I'm trying to setup the FluentEmail Razor Renderer but getting a bunt of errors due to missing default namespaces. For example

The type or namespace name 'List<>' could not be found

Is there a way to configure the default namespaces that the RazorLight engine uses?

rburnham52 avatar Nov 12 '20 02:11 rburnham52

I'm getting the same runtime exceptions, my code example is attempting to render a model that has a List<>

The Page (.cshtml) to be rendered by RazorLight is like this:

@using RazorLight
@inherits TemplatePage<List<MyModel>>

@{
    Layout = "<namespace path of layout.cshtml>";
}

@foreach (var element in Model)
{
    // Html Rendering
}

Per @ryburn52 's Q, do we need to add any additional declaration for this to work?

Simonl9l avatar Apr 14 '21 02:04 Simonl9l

@Simonl9l I ended up debugging this and their was a limitation with the Razor Light Library and the current FluentEmail implementation. we ended up using a different library

Details can be found here https://github.com/toddams/RazorLight/issues/387

rburnham52 avatar Apr 14 '21 05:04 rburnham52

@ryburn52 - thanks for the pointer.

@lukencode - Hi there, per above, don't suppose there are any plans to resolve the issue identified in detail by @ryburn52 ?

As a work around it seem if one embeds the List<Model> as a property in another model and use that in the TemplatePage<Model> things seem to work, the cost of another level of indirection is not entity ideal is workable, and may at least help others in a similar scenario.

Simonl9l avatar Apr 14 '21 05:04 Simonl9l