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

@route directive and source generator for route name constants #1883

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomasherceg
Copy link
Member

Registering all routes individually in DotvvmStartup.cs is painful. I've added an option to use @route directive in DotHTML markup files and have the route auto-generated using source generator.

The results looks as follows:

using DotVVM.Framework.Routing;

namespace DotVVM.Samples.Common
{
    public static class DotvvmRoutes
    {
        // constants for all route names (generated from relative path in the project directory)
        public const string Default = nameof(Default);

        // generated method that will be called from DotvvmStartup to register all routes
        public static void RegisterRoutes(DotvvmRouteTable routes) {
            routes.Add("Default", "test", "Views/Default.dothtml");
        }
    }
}

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

Successfully merging this pull request may close these issues.

1 participant