-
Notifications
You must be signed in to change notification settings - Fork 648
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
Allow users of components to receive data in the body of a custom tag #656
Comments
I think it would be confusing to use the parens to define variables for the <list items=input.items>
<@item renderBody(data)>
${data.name}
</@item>
</list> I'm not really a fan of this either, because technically it becomes Maybe the following?: <list items=input.items>
<@item input(data)>
${data.name}
</@item>
</list> With destructuring?: <list items=input.items>
<@item input({name})>
${data.name}
</@item>
</list> |
After giving it some more thought, it only makes sense to declare additional parameters for a {
"<item>": {
"var": { "nameFromAttribute": "var" }
}
} With this tag definition. The user would just need to do the following: <list items=input.items>
<@item var="theItem">
${theItem.name}
</@item>
</list> If the user didn't provide the
I think this is the best approach, but I think the following would be the next best alternative:
|
I would like to see something like this... I use freemarker server side with a similar feature : http://freemarker.org/docs/ref_directive_macro.html#autoid_114 I 'hack' it in marko like this :
|
Here's another proposal that introduces a new syntax for declaring the <await(userPromise)> (user) =>
Hello ${user.name}!
</await>
// Destructuring would also be allowed:
<await(userPromise)> ({ name }) =>
Hello ${name}!
</await>
// A one-liner would also be supported:
<await(userPromise)> (user) => Hello ${user.name}!</await>
// A new line should also probably be allowed:
<await(userPromise)>
(user) => Hello ${user.name}!
</await>
// Or, if you don't need to receive data :)
<await(userPromise)>Hello!</await> Here's another example that makes use of an alternative to HOCs for watching the scroll position (based on what is described in "I’m Breaking up with Higher Order Components."): <div>
<scroll-watch> (x,y) =>
<show-pos x=x y=y />
</scroll-watch>
</div> NOTE: let { x, y } = this.state;
this.input.renderBody(out, x, y); Here's another example based on the list rendering use case described in the original comment for this GitHub issue: <list items=input.items>
<@item> (item) =>
${item.name}
</@item>
</list> Pros:
Cons:
<ul>
<for(colors)> (color) =>
<li>${color}</li>
</for>
</ul> |
<include>
calls
I prefer to have the argument names defined inside the tag Anyone have an idea about other ways to do it ? What about using a pipe to delimit the input args from the output arg names for example : <tagName inputArg1=inputValue1 | ourputVar1>
${outputVar1}
</tagName>
<ul>
<for(colors) | color>
<li>${color}</li>
</for>
</ul>
<list items=input.items>
<@item | item>
${item.name}
</@item>
</list>
Could use brackets around the output parameter names if there are more than 1
<forEachEntryInMap map=map | (key, value) >
${key} ${value}
</forEachEntryInMap> Food for thought |
Implemented in #1076 |
New Feature
Description
list.marko
page.marko
Open Questions
Typically,
<tag(data)>
has been used to pass data to the tag, not receive data. Is this a good pattern?The text was updated successfully, but these errors were encountered: