<commit_before># jQuery-handlebars - v1.1.2

A jQuery plugin for alleviating the strain out of using the wonderful [Handlebars](http://handlebarsjs.com/) template framework.

## What exactly is jQuery-handlebars?

How many times have you found yourself writing the following code over and over again? Quite laborious isn't it?
Surely using a template framework is meant to make our "developing" lives a little easier?

```javascript
    // Cache the jQuery object of where to append the template
    var $content = $('#content');

    // Get the HTML of the template only
    var html = $('#my-template').html();

    // Compile the template
    var template = Handlebars.compile(html);

    // Data to pass to the template
    var context = {demo: 'This is a simple demo'};

    // Append the template to the content element
    $content.append(template(context));
```

As you can see, if you do this multiple times over the course of your project it can become bloated and quite repetitive (seems I repeated myself there!). Then there is the issue of injecting a template into an element with the ability to remove or replace at some point. Then you're talking about a lot more boilerplate code and for what? Wouldn't it be great if there was a jQuery plugin (there is) that allowed me to specify a template, append to the content element and keep record of those that have been compiled before? With the additional bonus of being able to remove a single template or all templates from the content element. Well you're in luck...

## jQuery-handlebars is as simple as 1-2-3, no really, it's that simple.

```javascript
    <!--Use the minified version for better performance-->
    <script src="jquery-handlebars.min.js"></script>

    <script>
        // Cache the jQuery object of where to append the template
        var $content = $('#content');

        // Data to pass to the template
        var context = {demo: 'This is a simple demo'};

        // Append the template to the content element
        //  'add': action
        //  '#my-template': template id string or jQuery selector object
        //  context: context data to pass to the template
        $content.handlebars('add', '#my-template', context);

        // It's that easy!
    </script>
```
The plugin will basically take care of compiling the template (if it hasn't been done already), mark in the DOM that it's a template by wrapping in a div with a data-* attribute (`data-jquery-handlebars`) and append to the content element.
How easier could it be? It could probably even make you a sandwich if it wanted to!

## How to install

If you use bower, then just copy and paste the following command to the shell window. (**Note:** jQuery-handlebars was already taken so I had to opt for 2)
```shell
	bower install jquery-handlarbars2
```

Otherwise just include `jquery-handlebars.min.js` somewhere in your document and preferable after jQuery (since it relies on jQuery).<commit_msg>Fixed typo<commit_after># jQuery-handlebars - v1.1.2

A jQuery plugin for alleviating the strain out of using the wonderful [Handlebars](http://handlebarsjs.com/) template framework.

## What exactly is jQuery-handlebars?

How many times have you found yourself writing the following code over and over again? Quite laborious isn't it?
Surely using a template framework is meant to make our "developing" lives a little easier?

```javascript
    // Cache the jQuery object of where to append the template
    var $content = $('#content');

    // Get the HTML of the template only
    var html = $('#my-template').html();

    // Compile the template
    var template = Handlebars.compile(html);

    // Data to pass to the template
    var context = {demo: 'This is a simple demo'};

    // Append the template to the content element
    $content.append(template(context));
```

As you can see, if you do this multiple times over the course of your project it can become bloated and quite repetitive (seems I repeated myself there!). Then there is the issue of injecting a template into an element with the ability to remove or replace at some point. Then you're talking about a lot more boilerplate code and for what? Wouldn't it be great if there was a jQuery plugin (there is) that allowed me to specify a template, append to the content element and keep record of those that have been compiled before? With the additional bonus of being able to remove a single template or all templates from the content element. Well you're in luck...

## jQuery-handlebars is as simple as 1-2-3, no really, it's that simple.

```javascript
    <!--Use the minified version for better performance-->
    <script src="jquery-handlebars.min.js"></script>

    <script>
        // Cache the jQuery object of where to append the template
        var $content = $('#content');

        // Data to pass to the template
        var context = {demo: 'This is a simple demo'};

        // Append the template to the content element
        //  'add': action
        //  '#my-template': template id string or jQuery selector object
        //  context: context data to pass to the template
        $content.handlebars('add', '#my-template', context);

        // It's that easy!
    </script>
```
The plugin will basically take care of compiling the template (if it hasn't been done already), mark in the DOM that it's a template by wrapping in a div with a data-* attribute (`data-jquery-handlebars`) and append to the content element.
How easier could it be? It could probably even make you a sandwich if it wanted to!

## How to install

If you use bower, then just copy and paste the following command to the shell window. (**Note:** jQuery-handlebars was already taken so I had to opt for 2)
```shell
	bower install jquery-handlarbars2
```

Otherwise just include `jquery-handlebars.min.js` somewhere in your document and preferably after jQuery (since it relies on jQuery).
{'fraction_non_alphanumeric': 0.08008109477952356, 'fraction_numerical': 0.0027031593174522725, 'mean_word_length': 3.4113263785394934, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3536321', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1440, 'n_words': 834}