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

Support for accessing HTML template's holes dynamically #201

Closed
ivaylo5ev opened this Issue Oct 25, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@ivaylo5ev

ivaylo5ev commented Oct 25, 2018

As per WebSharper 3 documentation examples one could access holes dynamically by passing the hole name as a string:

HTML Template

<article>
  <h2>${title}</h2>
  <section class="main" data-hole="content"></section>
</article>

F# Code

type Article =
    {
        Title : string
        Content : list<Element>
    }

let ArticleTemplate =
        Content.Template<Article>("~/Article.html")
            .With("title", fun x -> x.Title)
            .With("content", fun x -> x.Content)

I cannot seem to find a way to do this with the new type provider. Currently I face a scenario, as described in my stackoverflow post, where I need to populate a content hole without knowing its name at compile time. Unless I am missing something, I feel the current implementation does not cover my case.

Would it be possible to add the ability to access holes dynamically even from type-provider-managed template instances?

@ivaylo5ev ivaylo5ev changed the title from Support for accessing holes dynamically to Support for accessing HTML template's holes dynamically Oct 27, 2018

@Tarmil

This comment has been minimized.

Member

Tarmil commented Oct 29, 2018

Yes, this makes sense and should be useful.

I have a preliminary implementation of .With(name, value) for the type provider that I'll push soon. We may also want to have a type that is not provided, so that you can load fully dynamic templates; although it should basically be equivalent to Template<"<div>">.

@ivaylo5ev

This comment has been minimized.

ivaylo5ev commented Oct 30, 2018

This is great! I am looking forward for this to get merged. Thanks!

@Tarmil

This comment has been minimized.

Member

Tarmil commented Oct 30, 2018

This is now implemented (for the server side) and released as v4.5.5. I will open a separate issue for the client side version.

@Tarmil Tarmil closed this Oct 30, 2018

@Tarmil Tarmil added the 4.5.5.155 label Oct 30, 2018

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