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

Instatiation of the template doesn't work on client (C#) #189

Closed
V0d01ey opened this issue Sep 11, 2018 · 3 comments
Closed

Instatiation of the template doesn't work on client (C#) #189

V0d01ey opened this issue Sep 11, 2018 · 3 comments
Assignees

Comments

@V0d01ey
Copy link

V0d01ey commented Sep 11, 2018

When trying to instantiate a html-template in a new client-server application (from the project template) WS doesn't find it writing this line to console:

Local template doesn't exist null WebSharper.UI.js:5817

Html-file containing only a form is named:

UploadDialogTemplate.html

It's generated cs-file is:

UploadDialogTemplate.g.cs

And class is named:

Uploaddialogtemplate

WS seeks for key uploaddialogtemplate.

    [JavaScript]
    public static class Client
    {
        static public IControlBody Main()
        {
            var rvInput = Var.Create("");
            var submit = Submitter.CreateOption(rvInput.View);
            var vReversed =
                submit.View.MapAsync(input =>
                {
                    if (input == null)
                        return Task.FromResult("");
                    return Remoting.DoSomething(input.Value);
                });
            return div(
                input(rvInput),
                button("Send", submit.Trigger),
                hr(),
                h4(
                    attr.@class("text-muted"),
                    "The server responded:",
                    div(
                        attr.@class("jumbotron"),
                        h1(vReversed)
                    )
                ),
                new Template.Uploaddialogtemplate().Doc()   // <--  this line was added
            );
        }
    }

PS. Also, it would be great if generated cs-file was automatically included to c#-project.

@Tarmil
Copy link
Member

Tarmil commented Sep 14, 2018

What's happening here is that the templating system is trying to load the template contents from the DOM, assuming that the template corresponds to the current HTML document, instead of embedding it in the compiled javascript.

The cause is a really silly bug that I'll fix immediately: arguments aren't passed along correctly here.

Until this fix is released you can override this by adding the following to the top of your HTML file:

<!-- ClientLoad = Inline -->

PS. Also, it would be great if generated cs-file was automatically included to c#-project.

I'm not certain the Roslyn analyzer API allows this kind of modification. @Jand42 you know much more than me about Roslyn, is this possible? It would be nice.

@V0d01ey
Copy link
Author

V0d01ey commented Sep 24, 2018

@Tarmil ,
the problem was not solved.

@Tarmil
Copy link
Member

Tarmil commented Sep 24, 2018

Oh right sorry for the confusion indeed. For a template that is not used as the served index file, the comment is mandatory:

<!-- ClientLoad = Inline -->

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

No branches or pull requests

2 participants