Grantlee in use

The first release of Grantee is only 6 weeks old, but already third party developers are investigating the features it offers and the possibilities templating brings to their applications.

Ronny Yabar is using Grantlee for theming of KMail and broader KDEPIM as part of his Google Summer of Code project and has already made promising progress and uncovered a bug (fixed in Grantlee 0.1.1).

GSOC also brought an opportunity for Yiannis Belias to use Grantlee for code generation. Yiannis is doing a project this year for OpenICC, a color management platform. The project involves refactoring a lot of existing code, some of which includes a lot of repetition. Templating is being used to simplify the process of generating refactored code, generating new classes and possibly become a more long-term solution to the maintenance needs of the codebase.

Ryan Paul of ArsTechnica showed me a prototype of a twitter client using Grantlee. A simple template is used to generate html which is then shown using a QWebView.

Twitter client written in Qt using Grantlee to render the html

The template itself is mostly just a simple loop to generate the table.

<div class="messages">
     {% for m in messages %}
        <div id="{{ m.id }}" class="message" style="border: 2px solid {{ m.color }}; border-left: 7px solid {{ m.color }};">
         <table>
           <tr>
             <td>
               <a href="{{ m.profile_url }}">
                 <div class="imgbox" title="{{ m.sender_nick }}" style="background-image: url({{ m.image }});"></div>
               </a>
             </td>
             <td>
               <p class="content">
                 <span class="title">{{ m.sender }}</span>
                 <span class="time"> (<a href="{{ m.url }}">{{ m.time|timesince }}</a>)</span><br />
                 <span class="text">{{ m.html|safe }}</span>
               </p>
             </td>
           </tr>
         </table>
        </div>
     {% endfor %}
  </div>

Ryan has moved on to using Qt Quick for his twitter client. However, this has given me some ideas on how I can make it easier to use Grantlee for these kinds of tasks.

Arduide is also using Grantlee for html generation, such as the built in documentation and examples browser. A simple map is easily expanded with some loops into a summary page of all examples.

The themed browser content in Arduide is generated using Grantlee

These are just some of the things made possible by an accessible templating system. I have many more ideas of how it can be used, and I’m sure many other people will too.

One Response to “Grantlee in use”

  1. How do you use Grantlee? | Steveire's Blog Says:

    […] I’m giving a talk about it in just over a week (the first since 2009), and I’m wondering how people are using it these days. The last time I really investigated this was 6 years ago. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: