owncloud/core — pull request #2769 by tanghus (2013-04-06 21:37:10+00:00)
Title: Add octemplate jQuery plugin

jQuery plugin for micro templates

Strings are automatically escaped, but that can be disabled by setting escapeFunction to null.

Usage examples:

```
var str = 'Bake, uncovered, until the {greasystuff} is melted and the {pasta} is heated through, about {min} minutes.'
$(str).octemplate({greasystuff: 'cheese', pasta: 'macaroni', min: 10});

var str = 'Welcome back {user}';
$(htmlStr).octemplate(
{user: 'John Q. Public'},
{escapeFunction: null}
);
```
The latter is of course a bad example, but you get the drift I hope ;)

For anything larger than one-liners, you can use a simple $.get() ajax request to get the template, or you can embed them it the page using the text/template type:

```

```

And in you code:

```
var $tmpl = $('#contactListItemTemplate');
var contacts = // fetched in some ajax call

$.each(contacts, function(idx, contact) {
$contactList.append(
$tmpl.octemplate({
id: contact.getId(),
name: contact.getDisplayName(),
email: contact.getPreferredEmail(),
phone: contact.getPreferredPhone(),
});
);
});
```

This is **not** meant as a full-fledged templating framework, but for making simple scripts easier, while avoiding XSS in the process.
That being said the entire Contacts app is build using this simple plugin ;)

@bartv2 @LukasReschke @Raydiation @georgehrke