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

Docs should speak to the differences between html`` TTLs in other frameworks #100

Open
jessehattabaugh opened this issue Oct 23, 2022 · 2 comments
Labels
docs Additions or changes to documentation

Comments

@jessehattabaugh
Copy link

jessehattabaugh commented Oct 23, 2022

Enhance is not the first framework to construct DOM from an html tagged template literal. For example LitHTML also uses a TTL, and so some users may be familiar with using it. The difference between LitHTML and enhance is that LitHTML requires all the strings that you concat to be html. Enhance only requires the return value of the function to be tagged. It could eliminate some confusion if this were called out explicitly.

@kristoferjoseph
Copy link
Contributor

Can you elaborate on this a bit?
Maybe a code example would help me understand what it is specifically that I can add to make this more clear.
We don't do comparisons as not to be perceived as throwing shade at other people's hard work, but I feel that there is a subtle distinction here you are trying to outline that is lost on me.

Thanks!

@macdonst macdonst added the docs Additions or changes to documentation label Dec 12, 2022
@jessehattabaugh
Copy link
Author

I think that this section needs to be rearranged: https://enhance.dev/docs/learn/concepts/html/

The index should explain the concepts of Custom Element expansions, and maybe the differences between that and the "pages" which are authored in *.html files.

Then, after you introduce the concept of render functions, you should mention the argument object and explain the purpose of it's two properties state and html.

The current index.mjs doesn't actually talk about the html argument and how it is supposed to be used, so I think there could be a new page which does so. It could read like this:

"render functions receive an argument with a property called html. The return value of the render function must be a tagged template literal that uses the html function as a tag. This function allows you to construct dynamic markup by adding variable values inside of ${} {whatever those are called}."

here's the important part:

"Note: many popular frameworks allow you to construct markup with a TTL. Enhance's html does not require that all strings included in ${} also be html tagged template literals."

"Example:

in LitElement

html`
  ${user.isloggedIn
      ? html`Welcome ${user.name}`
      : html`Please log in`
  }
`;

in enhance it's just:

html`
  ${user.isloggedIn
      ? `Welcome ${user.name}`
      : `Please log in`
  }
`;

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

No branches or pull requests

3 participants