New Site Liquid Drop added

April 28th, 2011 by admin

I’m starting this section on the Mephisto site to talk about breaking changes as I develop. There are certain things (regarding the liquid templates especially) that are rapidly changing. The first big change is the loss of the sections variable.

Until now, you could use {% for section in sections.list %} to enumerate through the sections. I’ve started converting everything to Liquid Drops and decided to create a ‘site’ drop instead. Change the above to {% for section in site.sections %}. There are a few odd cases that I’ve added:

* {% for section in site.blog_sections %} lists only blog sections.
* {% for section in site.page_sections %} lists only paged sections.

(Each article is a liquid drop too and now has the same methods)

If you want to do something else like, list all but home sections, this is how we’re doing it now:

{% for section in site.sections %}
{% if section.path != ‘home’ %}

{% endif %}
{% endfor %}

I’m still experimenting and looking for the best option. Let me know if you have suggestions.

What is a Liquid Drop?

Here’s a quick Liquid Drop crash course. By default, it lets you set up variables used in the templates as hashes. When you do {{ article.title }}, it converts that to article[‘title’] basically. Sometimes though, you don’t want to preload everything. If selecting an article always selected the comments and sections every time, the site could get pretty slow.

So, here come Liquid Drops. They are basically a blank slate liquid variable. It can wrap around a liquid variable’s existing keys, and provide custom methods that load data. Something like {{ site.sections }} will now load all the sections the first time they’re accessed.

This gives us the possibility of performing some custom operations in the future, like {{ site.find_section(‘foo’).articles }}. This also lets someone make a Flickr plugin, for instance, with: {% for image in flickr.recent_images %}. Wouldn’t that be cool?

Posted in Mephisto Setup, Social

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.