Attribute splats #69

Closed
jaen opened this Issue Aug 20, 2012 · 2 comments

Projects

None yet

2 participants

@jaen
jaen commented Aug 20, 2012

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
</p>

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.

@aaronblohowiak
Collaborator

Are there tests? Is it in its own branch?

@jaen
jaen commented Aug 20, 2012

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