-
Notifications
You must be signed in to change notification settings - Fork 1k
[lit-html] Add when, map, join, and range directives. #2335
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
Conversation
🦋 Changeset detectedLatest commit: f6003ea The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
|
We had this discussion offline, writing up here: From a usage perspective, these new helpers seem to be in the same category as directives. The difference is really just an implementation detail -- that these ones don't need to use the E.g. it could be difficult for users to remember that Some options:
|
|
I like this option:
|
|
Moved the helpers into directives/ |
aomarks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
@kevinpschaaf are you good with this now? |
These helpers are simple functions, not directives, that help make a template read a bit more declaratively when containing conditionals and loops. They're not strictly necessary, but we've found a number of users ask for them or write their own.
Adds:
when(): sugar for ternaries. Especially nice when there's no else clausemap(): Evaluate a function of items in an iterable. Stylistically more "declarative" and works with iterables.join(): Interleaves the items of an iterable with a joiner value or result of calling a joiner function.range(): Returns an iterable that contains number in a range. Useful when combined withmap().