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

Support splat attributes #44

Open
doomspork opened this issue Oct 9, 2015 · 3 comments
Open

Support splat attributes #44

doomspork opened this issue Oct 9, 2015 · 3 comments

Comments

@doomspork
Copy link
Member

Splat converts a hash into attribute key/value pairs.

Slim:

.card*{'data-url'=>place_path(place), 'data-id'=>place.id} = place.name

HTML:

<div class="card" data-id="1234" data-url="/place/1234">Slim's house</div>

See slim docs: Splat Attributes.

@henrik
Copy link
Contributor

henrik commented Oct 11, 2015

Crucially, the hash can be returned indirectly:

.card *method_which_returns_hash = place.name
.card *@hash_instance_variable = place.name

I guess in Elixir, it could make sense to support expressions that evaluate to any type of dict, whether that's a keyword list or a map.

As for literal hash syntax, do you think it makes more sense to support the Ruby hash syntax (in your example above) for compatibility with Ruby-Slim, or to instead use some (or every) Elixir dict syntax? I'm thinking the latter.

@doomspork
Copy link
Member Author

Sorry those examples were copied and pasted directly from the Slim documentation, we should definitely use Elixir dict syntax.

@henrik
Copy link
Contributor

henrik commented Oct 12, 2015

👍

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

No branches or pull requests

2 participants