Skip to content

Instantly share code, notes, and snippets.

@jacine
Created April 22, 2012 20:18
Show Gist options
  • Save jacine/2466618 to your computer and use it in GitHub Desktop.
Save jacine/2466618 to your computer and use it in GitHub Desktop.
Options?
{% helperclasses on %}
<!-- Simple example (default) -->
{% if items %}
<{{ type }}{{ items.attributes }}>
{% for item in items %}
<li{{ item.attributes }}> {{- item -}} </li>
{% endfor %}
</{{ type }}>
{% endif %}
<!-- More granular example -->
{% if items %}
<{{ type }}{{ items.attributes }}>
{% for item in items %}
{% if item.attributes.href %}
<li><a href="{{ item.attributes.href }}"> {{ item.title }} </a></li>
{% else %}
<li>{{- item -}}</li>
{% endif %}
{% endfor %}
</{{ type }}>
{% endif %}
@AmyStephen
Copy link

Should line 12 be item.title ?

@jacine
Copy link
Author

jacine commented Apr 22, 2012

Hey @AmyStephen!

I think it's actually item.attributes.title, and item.attributes.href now. Not sure though. I was just trying to demonstrate the top part, which is actually going to be like this: {% helperclasses on %} I believe. This would be a toggle setting for adding first/last/even/odd classes.

I'll update it when I figure it out. :)

@jacine
Copy link
Author

jacine commented Apr 22, 2012

BTW, trying to solve this uglyness (more recent example) without making designers go into preprocess functions: http://pastebin.com/peftf8gz :P

@AmyStephen
Copy link

Looks fantastic, @jacine. You are doing great work. Love watching you lead. =)

@AmyStephen
Copy link

OMG. lol. If you pull this off, you will never have to buy beer at a Drupalcon again.

@jacine
Copy link
Author

jacine commented Apr 22, 2012

LOL! That would be awesome. :D

I updated it to what I think it's gonna be. ;)

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