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

Templating: enable making Var holes without a corresponding input element #206

Open
Tarmil opened this issue Feb 19, 2019 · 0 comments
Open
Labels

Comments

@Tarmil
Copy link
Member

Tarmil commented Feb 19, 2019

This would be particularly useful in a server-side scenario where you just want a small client function to toggle a value, for example:

<button ws-onclick="ShowPanel">Show</button>
<button ws-onclick="HidePanel">Hide</button>
<div id="panel" class="${PanelClass}"></div>
MyTemplate()
    .HidePanel(fun e -> e.Vars.PanelClass := "hidden")
    .ShowPanel(fun e -> e.Vars.PanelClass := "")
    .Doc()

Right now the above doesn't work, because PanelClass can only be bound as a string or View<string>, not Var<string>. It is only doable by adding something like this in the HTML, but it's quite hackish:

<input type="hidden" ws-var="PanelClass">

I'm not sure what form this would take, but it needs to be known statically. Ideas:

  • Use a special syntax when declaring the hole itself, such as ${!Name}.

  • Pass a list of vars when declaring the provider:

    type MyTemplate = Template<"index.html", Vars = "PanelClass,SomeOtherVar">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant