About this documentation node js v5 3

Page 218

npm install --save-dev grunt-lint-pattern

Then add grunt-lint-pattern to the list of modules to be loaded in Gruntfile.js, and add the following configuration: lint_pattern: { view_statics: { options: { rules: [ { pattern: /<link [^>]*href=["'](?!\{\{static )/, message: 'Un-mapped static resource found in <link>.' }, { pattern: /<script [^>]*src=["'](?!\{\{static )/, message: 'Un-mapped static resource found in <script>.' }, { pattern: /<img [^>]*src=["'](?!\{\{static )/, message: 'Un-mapped static resource found in <img>.' }, ] }, files: { src: [ 'views/**/*.handlebars' ] } }, css_statics: { options: { rules: [ { pattern: /url\(/, message: 'Un-mapped static found in LESS property.' }, ] }, files: { src: [ 'less/**/*.less' ] } } }

And add lint_pattern to your default rule: grunt.registerTask('default', ['cafemocha', 'jshint', 'exec', 'lint_pattern']);

Now when we run grunt (which we should be doing regularly), we will catch any in� stances of unmapped statics.

196

| Chapter 16: Static Content

www.it-ebooks.info


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.