slime icon indicating copy to clipboard operation
slime copied to clipboard

Support splat attributes

Open doomspork opened this issue 10 years ago • 3 comments

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.

doomspork avatar Oct 09 '15 20:10 doomspork

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.

henrik avatar Oct 11 '15 11:10 henrik

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

doomspork avatar Oct 11 '15 16:10 doomspork

:thumbsup:

henrik avatar Oct 12 '15 20:10 henrik