1 | # grunt-dust [![build status](https://secure.travis-ci.org/vtsvang/grunt-dust.png)](http://travis-ci.org/vtsvang/grunt-dust)
|
2 |
|
3 | Grunt.js plugin to compile dustjs templates.
|
4 |
|
5 | ## Getting Started
|
6 | This plugin requires Grunt `~0.4.0`
|
7 |
|
8 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
|
9 |
|
10 | ```shell
|
11 | npm install grunt-dust --save-dev
|
12 | ```
|
13 |
|
14 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
|
15 |
|
16 | ```js
|
17 | grunt.loadNpmTasks('grunt-dust');
|
18 | ```
|
19 |
|
20 | *This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.1.1](https://github.com/vtsvang/grunt-dust/tree/v0.1.0).*
|
21 |
|
22 |
|
23 |
|
24 | ## Dust task
|
25 | _Run this task with the `grunt grunt-dust` command._
|
26 |
|
27 | Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.
|
28 | ### Options
|
29 |
|
30 | #### wrapper
|
31 | Type: `String/boolean`
|
32 | Default: "amd"
|
33 |
|
34 | Wrapper style to use - "amd" or "commonjs" are the only accepted values.
|
35 |
|
36 | #### wrapperOptions
|
37 | Type: `Object`
|
38 | Default: null
|
39 |
|
40 | Options for the package wrapper.
|
41 |
|
42 | #### wrapperOptions.packageName
|
43 | Type: `String`
|
44 | Default: null
|
45 |
|
46 | Package name used in define() invocation.
|
47 |
|
48 | #### wrapperOptions.returning
|
49 | Type: `String`
|
50 | Default: "dust"
|
51 |
|
52 | Name of variable which will be returned in CommonJS wrapper.
|
53 |
|
54 | #### wrapperOptions.deps
|
55 | Type: `Object`
|
56 | Default: { dust: "dust-runtime" }
|
57 |
|
58 | Amd package dependencies.
|
59 |
|
60 | #### runtime
|
61 | Type: `boolean`
|
62 | Default: true
|
63 |
|
64 | Include dust runtime file.
|
65 |
|
66 | #### relative
|
67 | Type: `boolean`
|
68 | Default: false
|
69 |
|
70 | Make templates names relative from cwd (working only if used [Grunt Dynamic Mappings](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically)).
|
71 |
|
72 | #### basePath
|
73 | Type: `string`
|
74 | Default: false
|
75 |
|
76 | Exclude this path from templates names.
|
77 |
|
78 |
|
79 | ### Usage Examples
|
80 |
|
81 | ```js
|
82 | dust: {
|
83 |
|
84 | defaults: {
|
85 | files: {
|
86 | "dst/default/views.js": "src/**/*.dust"
|
87 | },
|
88 | },
|
89 |
|
90 | many_targets: {
|
91 | files: [
|
92 | {
|
93 | expand: true,
|
94 | cwd: "src/",
|
95 | src: ["**/*.dust"],
|
96 | dest: "dst/many-targets/",
|
97 | ext: ".js"
|
98 | }
|
99 | ],
|
100 | options: {
|
101 | relative: true
|
102 | }
|
103 | },
|
104 |
|
105 | no_wrapper: {
|
106 | files: {
|
107 | "dst/views_no_amd/views.js": "src/**/*.dust"
|
108 | },
|
109 | options: {
|
110 | wrapper: false
|
111 | }
|
112 | },
|
113 |
|
114 | amd_custom_deps: {
|
115 | files: {
|
116 | "dst/views_amd_custom_deps/views.js": "src/**/*.dust"
|
117 | },
|
118 | options: {
|
119 | wrapper: "amd",
|
120 | wrapperOptions: {
|
121 | deps: {
|
122 | dust: "dust-core-1.0.0.min.js"
|
123 | }
|
124 | }
|
125 | }
|
126 | },
|
127 |
|
128 | amd_without_deps: {
|
129 | files: {
|
130 | "dst/views_amd_without_deps/views.js": "src/**/*.dust"
|
131 | },
|
132 | options: {
|
133 | wrapper: "amd",
|
134 | wrapperOptions: {
|
135 | deps: false
|
136 | }
|
137 | }
|
138 | },
|
139 |
|
140 | amd_with_package_name: {
|
141 | files: {
|
142 | "dst/views_amd_with_package_name/views.js": "src/**/*.dust"
|
143 | },
|
144 | options: {
|
145 | wrapper: "amd",
|
146 | wrapperOptions: {
|
147 | packageName: "views"
|
148 | }
|
149 | }
|
150 | },
|
151 |
|
152 | commonjs: {
|
153 | files: {
|
154 | "dst/views_commonjs/views.js": "src/**/*.dust"
|
155 | },
|
156 | options: {
|
157 | wrapper: "commonjs",
|
158 | wrapperOptions: {
|
159 | returning: "dust",
|
160 | deps: {
|
161 | foo: "foo.js",
|
162 | dust: "dust.js"
|
163 | }
|
164 | }
|
165 | }
|
166 | },
|
167 |
|
168 | nested_relative: {
|
169 | files: {
|
170 | "dst/views_nested_relative/views.js": "src/**/*.dust"
|
171 | },
|
172 | options: {
|
173 | wrapperOptions: {
|
174 | deps: false
|
175 | },
|
176 | basePath: "src/"
|
177 | }
|
178 | },
|
179 |
|
180 | no_runtime: {
|
181 | files: {
|
182 | "dst/views_no_runtime/views.js": "src/**/*.dust"
|
183 | },
|
184 | options: {
|
185 | runtime: false
|
186 | }
|
187 | }
|
188 |
|
189 | }
|
190 | ```
|
191 |
|
192 | For more examples on how to use the `expand` API to manipulate the default dynamic path construction in the `glob_to_multiple` examples, see "Building the files object dynamically" in the grunt wiki entry [Configuring Tasks](http://gruntjs.com/configuring-tasks).
|
193 |
|
194 | ## Release History
|
195 | * v0.6.0
|
196 | - Bring basePath option back into service. [Thanks to [Michael Gilley](https://github.com/michaelgilley)]
|
197 | * v0.5.5
|
198 | - Update dustjs-linkedin version to v2.0.2
|
199 | * v0.5.4
|
200 | - AMD wrapper now exports template(s) name. [Thanks to [silnijlos](https://github.com/silnijlos)]
|
201 | * v0.5.3
|
202 | - Update dustjs-linkedin version to v2.0.0
|
203 | * v0.5.2
|
204 | - Added "returning" option, which specifies the name of returning variable in CommonJS mode. [Thanks to [Wilson Wise](https://github.com/wilsonodk)]
|
205 | * v0.5.1
|
206 | - Resolve runtime path with semver
|
207 | - Update dustjs-linkedin version to 1.2.5
|
208 | * v0.5.0
|
209 | - Added CommonJS support. [Thanks to [Alastair Coote](https://github.com/alastaircoote)]
|
210 | - Two new properties "wrapper" and "wrapperOptions" instead of "amd".
|
211 | - Property "amd" is now deprecated
|
212 | - Added ability to define named dependencies ("deps" property stay object and no more compatible with previous version) [Idea by Daniel Suchy]
|
213 | * v0.4.1
|
214 | - Fixed compatibility with new coffee-script version. [Thanks to [Alastair Coote](https://github.com/alastaircoote)]
|
215 | * v0.4.0
|
216 | - Added option "relative". [Thanks to [Andy Engle](https://github.com/andyengle)]
|
217 | - Remove extension from templates names. [Thanks to [Andy Engle](https://github.com/andyengle)]
|
218 | * v0.3.5
|
219 | - Fixed issue with dustjs runtime path obtainment on Windows. [Thanks to Daniel Suchy]
|
220 | * v0.3.4
|
221 | - Obtain runtime destination without `fs.*` invocations. [Thanks to Daniel Suchy]
|
222 | * v0.3.3
|
223 | - Replaced grunt.js with Gruntfile.js in package.json
|
224 | * v0.3.2
|
225 | - Bump grunt dependency version
|
226 | * v0.3.1
|
227 | - Added usage examples
|
228 | - Added options documentation
|
229 | * v0.3.0
|
230 | - Support of final version of Grunt.js API (Thanks to Ian Parkins aka [@parkotron](https://github.com/parkotron))
|
231 | - Tests on Mocha
|
232 | - Tasks written on coffee compiles in runtime
|
233 | * v0.2.0
|
234 | - Support of new Grunt.js API
|
235 | - Refactored API according to Grunt.js updates
|
236 | * v0.1.1
|
237 | - Fixed issue with empty array of dependencies and added ability to set package name for AMD
|
238 | * v0.1.0
|
239 | - First release
|
240 |
|
241 | ## License
|
242 | Copyright (c) 2013 Vladimir Tsvang
|
243 | Licensed under the MIT license.
|