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

Remove prototype elements when data is present #55

Open
iamvery opened this issue Sep 27, 2016 · 6 comments
Open

Remove prototype elements when data is present #55

iamvery opened this issue Sep 27, 2016 · 6 comments

Comments

@iamvery
Copy link
Owner

iamvery commented Sep 27, 2016

Would like to be able to designate certain elements as prototype. This would allow multiple versions of a thing to be shown in prototype, but exclude it in the final render.

For example,

<div data-prop="foo">First</div>
<div data-proto="foo">Second</div>

When rendered with no data, the prototype would be included. However when rendered with data, it would look like:

data = %{foo: "lolwat"}
<div data-prop="foo">lolwat</div>
<!-- note the prototype element is excluded -->
@bryanp
Copy link

bryanp commented Sep 27, 2016

Interesting! I may steal this for Pakyow 😁

We have something called view versions that this would fit right into. For example:

<div data-prop="foo" data-version="default" class="foo">First</div>
<div data-prop="foo" data-version="alt" class="fooalt">First</div>
<div data-version="proto" class="fooproto">First</div>

When running in prototype mode, all versions are presented. Outside of that, default would be always be presented unless the backend chooses alt; proto would always be removed.

@dgmcguire
Copy link
Contributor

I think there would be less surprise for users of ratchet if you just had multiple props of the same name and have merged data overwrite everything, rather than have a more explicit tool for specifying prototype data I would rather have everything that is inside a data-prop to be by default considered prototype that can be overwritten by merged in data.

@iamvery
Copy link
Owner Author

iamvery commented Sep 27, 2016

Seems like a good idea @dgmcguire. Glad you like the idea @bryanp 😊

@bryanp
Copy link

bryanp commented Sep 27, 2016

Hmm maybe I misunderstood the purpose of this feature. In Pakyow, the innerContent of the node is overridden when the data is presented. What I thought you were getting at here is that sometimes nodes are needed for decoration that would never be presenting data, and thus not be a data-prop. Can you back up and explain more of your thinking here?

@iamvery
Copy link
Owner Author

iamvery commented Sep 27, 2016

The use case I'm trying to address is sometimes a prototype view needs multiple example elements to really drive the point of it home. I suppose the canonical example might be an actual list. If the <li> had a data-prop, the designer would probably want to illustrate that portion of the view with multiple list items for example. However, for rendering, only the first or "non prototype" item would be used. Does that make sense?

@bryanp
Copy link

bryanp commented Sep 27, 2016

Yep, got it. In Pakyow, this is a non-issue. When you look for a prop by name, it returns an object that represents every matching view prop at that level. Then, the data presentation method handles removing them (essentially making the view look like the data). I believe this is what @dgmcguire is getting at as well. So, looks like I misunderstood 😬

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

No branches or pull requests

3 participants