Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing template functions #428

Open
RedX2501 opened this issue Feb 5, 2021 · 0 comments
Open

Sharing template functions #428

RedX2501 opened this issue Feb 5, 2021 · 0 comments

Comments

@RedX2501
Copy link
Contributor

RedX2501 commented Feb 5, 2021

Looking up a lot of documentation it seems that much of the new workflow in razor with .Net Core and Blazor has the temlates being pre-compiled.

My use-case is a bit different, the user can provide their on templates which are rendered at runtime.

This has the problem that as soon as he has 2 or more templates he will probably have common functionality that he might want to use in both scripts.

With @{ await IncludeAsync(...);} it is already possible to reuse code fragment which is nice. Unfortunately you can't stored the returned value in a variable.

What I'd like to do though is to reuse (static) functions to be able to store the value. It used to be possible as indicated by this StackOverflow question and answer: https://stackoverflow.com/questions/6347447/shared-mvc-razor-functions-in-several-views

With him providing the templates to an already compiled software means that he can't extend the Model or write some new class to share the functions. Two common "solutions" I found for the problem.

I thought that it might work out of the box here with file system projects if I was lucky and all templates were inside the same dll but it seems the generated code is not like that.

So am I missing something and this feature is available but just under-documented?

If not I'd like to ask if you also think this feature request is sensible and whether we could plan to introduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant