Skip to content


Attribute splats #69

jaen opened this Issue · 2 comments

2 participants


I've had a JS object with some key-value pairs I wanted to put as attributes on tags, but it seemed that only way to do so is to manually maintain attributes for all the k-v pairs I have, which I thought was pretty inelegant and dumb maintenance-wise, so I went ahead and implemented splat syntax for attributes in my fork of ruby-haml-js.

It works like this:

%p{ attr: 'val', *splat }
    hurr durr

Which given splat: { sattr: 1, sattr2: 'derp' } as the argument to the template renders as such:

<p attr="val" sattr="1", sattr2="derp">
    hurr durr

I'm not sure if there is any need for such functionality and if it is a safe thing to do - I mean I use the escape func, but since the rendering of the splats has to be done client-side it may be can be tampered with somehow?
But if it feels lik a good addition, I can try to clean it up and port it back to the main library.


Are there tests? Is it in its own branch?


At the moment no, because i just hacked it to get it working pronto, but if you deem such feature interesting I can code it clean with tests et all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.