<commit_before># DustJS (LinkedIn) Loader

---

A loader for Webpack that compiles Dust templates into JavaScript to be used within the browser.

### Motivation

I initially looked at the default Dust loader [here](https://github.com/avaly/dust-loader), but unfortunatly it didn't meet my requirements. I wanted a simple way to control how templates were named and required. In the old loader, requiring templates didn't have much of a purpose. Instead I decided to both register the template and then return the name. This made the require more meaningful as it could be assigned to a variable and used with dust.render.

### Example

Below is a simple Webpack configuration (webpack.config.js).

```javascript
var Path = require("path");

module.exports = {
    entry: "./main.js",
    output: {
        filename: "bundle.js"
    },
    module: {
        loaders: [{
            test: /\.dust$/,
            loader: "dust",
            query: {
                // Absolute path to the views directory.
                path: Path.join(__dirname,  "views")
            }
        }]
    }
};
```

The path query property is important as it effects the naming of the template. With the current configuration "./views/example.dust" would resolve to "example". However, if the path property wasn't given, it would instead resolve to "views-example". 

**Note**

If you wish to use multiple paths, you can instead use the 'paths' property. The loader will iterate through the list of paths (including the context path) and find the closest match.

Next we will create the template (views/example.dust).

```
Hello, {name}!
```

Lastly, we need to require the template.

```javascript
var Dust = require("dustjs-linkedin");
var template = require("./views/example.dust");

Dust.render(template, {name: "<NAME>"}, function(err, result) {
    // result = "Hello <NAME>!"
});
```

### Options

You can pass options to the loader using the query object or directly within the loader string. By default, the path used by the loader to determine the name of the templates is 'this.options.context. More information [here](http://webpack.github.io/docs/loaders.html).

#### Path (String)
<commit_msg>Yet another typo fix<commit_after># DustJS (LinkedIn) Loader

---

A loader for Webpack that compiles Dust templates into JavaScript to be used within the browser.

### Motivation

I initially looked at the default Dust loader [here](https://github.com/avaly/dust-loader), but unfortunately it didn't meet my requirements. I wanted a simple way to control how templates were named and required. In the old loader, requiring templates didn't have much of a purpose. Instead I decided to both register the template and then return the name. This made the require more meaningful as it could be assigned to a variable and used with dust.render.

### Example

Below is a simple Webpack configuration file (webpack.config.js).

```javascript
var Path = require("path");

module.exports = {
    entry: "./main.js",
    output: {
        filename: "bundle.js"
    },
    module: {
        loaders: [{
            test: /\.dust$/,
            loader: "dust",
            query: {
                // Absolute path to the views directory.
                path: Path.join(__dirname,  "views")
            }
        }]
    }
};
```

The path query property is important as it effects the naming of the template. Using the current configuration, "./views/example.dust" would resolve to "example". However, if the path property isn't given, the template name would instead resolve to "views-example". 

**Note**

If you wish to use multiple paths, you can instead use the 'paths' property. The loader will iterate through the list of paths (including the context path) and find the closest match.

Next we will create the template (views/example.dust).

```
Hello, {name}!
```

Lastly, we need to require the template.

```javascript
var Dust = require("dustjs-linkedin");
var template = require("./views/example.dust");

Dust.render(template, {name: "<NAME>"}, function(err, result) {
    // result = "Hello <NAME>!"
});
```

### Options

You can pass options to the loader using the query object or directly within the loader string. By default, the path used by the loader to determine the name of the templates is 'this.options.context'. More information [here](http://webpack.github.io/docs/loaders.html).

#### Path (String)

{'fraction_non_alphanumeric': 0.10399636693914623, 'fraction_numerical': 0.0, 'mean_word_length': 3.2891918208373903, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2159015', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1131, 'n_words': 540}