conficient / BlazorTemplater

A library that generates HTML (e.g. for emails) from Razor Components
Apache License 2.0
146 stars 16 forks source link

Rendering a component requires adding Localization service despite the component not injecting it #25

Closed thomas-heath closed 2 years ago

thomas-heath commented 2 years ago

When trying to use this library to make html from a component I get this error: image

It pops up when calling Render, here's the code for the rendering and the component: image image

I've gotten rid of the error by adding Localizer as a service, but that begs the question as to why that component is trying to use Localizer in the first place?

My first theory was that it was using the MainLayout, but that doesn't contain any reference to Localizer. The only other place I can think of that it would be requesting this service is in _Imports.razor, but why would this component be pulling from there?

thomas-heath commented 2 years ago

My mistake, I believe in making this issue that I stumbled upon the cause. The compiler automatically applies the contents of _Imports.razor to every razor file in its directory and sub-directories, so every component in the project was injecting localizer.

conficient commented 2 years ago

OK glad you found the cause! Yes the library has no dependency on a localizer.