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

Splat operator (conditional attributes) support? #29

Open
wulftone opened this issue Jun 28, 2013 · 4 comments
Open

Splat operator (conditional attributes) support? #29

wulftone opened this issue Jun 28, 2013 · 4 comments

Comments

@wulftone
Copy link

EDIT: Discovered the Splat operator, re-writing...

I'm trying to set up a conditional attribute... for example, I want the result to be one of the two following:

<a>Lotsa content</a>

or

<a href="some/link">Lotsa content</a>

The condition would be whether or not the href exists. So the skim pseudo-code would be something like this:

a *( if @url then { href: @url } else {} )
  Lotsa content

I know that doesn't work, obviously, but I can't find any way to do this in skim. Slim supports it via their splat operator. The "correct" coffeescript version would be like the example just above. In ruby/slim it's a *( @url ? { href: @url } : {} )

I'd rather not do this:

- if @url
  a href='#{@url}'
    Lotsa content
- else
  a
    Lotsa content

Because "Lotsa content" is a ton of code duplication. I also don't want the href in the a tag, because clicking on an empty href causes the page to reload. I could make the link do nothing when clicked on if there's no href, but it would be much easier just to omit the href and let that behavior happen naturally.

Would it be possible to implement the splat operator?

@jfirebaugh
Copy link
Collaborator

Yeah, skim should support all the same language constructs as slim, including the splat operator.

@wulftone
Copy link
Author

wulftone commented Jul 8, 2013

I'm not sure what you mean by "should support". Do you mean it currently does, or that you're working on it?

@jfirebaugh
Copy link
Collaborator

Sorry, that was ambiguous. I mean, the design goal of skim is to support the same syntax as slim (modulo CoffeScript for Ruby). So the current lack of splat operator support is a bug.

@mahemoff
Copy link

mahemoff commented Dec 3, 2015

Does this mean there's no way to do dynamic attributes with Skim at present? I'm trying to generate a tag where the "data-*" attributes vary.

Not sure if there's some other way to do it?

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

No branches or pull requests

3 participants