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

Suggestion: Run-time evaluated attributes. #130

Closed
eedahl opened this issue May 22, 2018 · 7 comments
Closed

Suggestion: Run-time evaluated attributes. #130

eedahl opened this issue May 22, 2018 · 7 comments
Labels

Comments

@eedahl
Copy link

eedahl commented May 22, 2018

This may be a non-issue in the current build or there could be a workaround, but I see from the documentation that attributes only accept string literals and .attr with the [] bracket. The program I'm making is primarily displaying tables, and some of the cells/rows have either on-click callbacks prescribed by class/id in JS that depend on the row number (of which there are 50+), and many of the cells have colouring depending on a class attribute (of which there are 7). Obviously, typing these all out and checking a bit for each would be rather cumbersome. From what I can tell so far this is the only thing holding this back from being the perfect templating system for my needs.

@eedahl
Copy link
Author

eedahl commented May 22, 2018

Sorry, I see this is already an open issue. #128

@lambda-fairy
Copy link
Owner

No worries. I appreciate these comments regardless, because they help me prioritize.

Are you aware of splices in attributes? Now that I mention it, I should probably link to that section from "non-empty attributes", since it's not obvious that there's more to the syntax.

@eedahl
Copy link
Author

eedahl commented May 23, 2018 via email

@eedahl
Copy link
Author

eedahl commented May 23, 2018

Maybe you have some ideas? Or maybe fleshing out my scenario would help work out what would be a good way to implement it. My incoming data is vector of structs containing row data R. So I want to loop over this and make rows for each entry. The has an id that is a concatenation of "lev-" and an i32 coming from R, which may not come in order. Two of the s in each row has (at least) a class determined independently from a string in R, and there are 7 different possibilities for each of them, and there may be other hard coded or conditional classes as well.

@lambda-fairy
Copy link
Owner

lambda-fairy commented May 26, 2018

@eedahl The class and id shorthands are no more than sugar around writing out the attributes in full. If they're generated dynamically, then it's okay to use the long form:

html! {
    tr id={ "lev-" (row.index) } {
        // ...
    }
}

Does this help?

@eedahl
Copy link
Author

eedahl commented May 26, 2018 via email

@lambda-fairy
Copy link
Owner

Closing in favor of #167

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

No branches or pull requests

2 participants