Overview

The plugin is designed to be analogous to jQuery. So if you understand jQuery, you can basically understand how this works. In jQuery, we are operating on the DOMwhich is a tree of html elements. In the HiFi API we are operating on our site, which is a tree of nodes. So in jQuery we might say:

$('li').each(function(){ alert($(this).html()); });

In the HiFi API, we can say:

hifi({type: page}).each(function(page){ alert(page.title); });

So just like jquery, it is broken into two parts, the selector (‘li’ or {type: ’page’}) and the chained methods (.each).

Including the plugin in your code

Before you can use the HiFi JS API, you must include an extra JavaScript file in your templates. You can do that as follows:

<script src="{{ hifi.url.jsapi }}" type="text/javascript"></script>