Skip to content

Options

Ryan Harvey edited this page Apr 24, 2014 · 8 revisions

Specifying Options

As with all Grunt tasks options may be specified for the task or target. In addition, options for the grunt-file-blocks task may be specified for a source file or an individual replacement block. Options are applied in the following order.

  1. Block level
  2. Source file level
  3. Target level
  4. Task level

Note: Options that are specified at the block level are not wrapped in an options object.

fileblocks: {
  options: {
    /* Task options */
  },
  your_target: {
    options: {
      /* Target options */
    }
    files: [
      {
        options: {
          /* Source file options */
        },
        src: 'app/index.html'
        blocks: [
          { name: 'block1', src: 'app/js/*.js', /* Block level options */ }
        ]
      }
    ]
  }
}

Options

removeBlock

Type: Boolean Default value: false

If true the entire block, including comment anchors, is removed during processing.

removeAnchors

Type: Boolean Default value: false

If true the comments that serve as a block anchor are removed during processing.

rebuild

Type: Boolean Default value: false

Removes all files from the block on each run and rebuilds based on the file matching patterns.

Note: This option overrides the removeFiles option.

removeFiles

Type: Boolean Default value: false

If true, lines that were previously added that no longer have a matching file will be removed.

prefix

Type: String Default value: undefined

A prefix that will be added to the path of every matched file before it is inserted into a block.

templates

Type: Object Default value: undefined

An object that defines values for templates. Templates may override the default templates or specify custom templates. The token %{file} will be replaced with a matched path and file name.

templates: {
  css: '<link href="${file}" rel="stylesheet" data-custom="value"/>'
  custom_md: '+ %{file}'
}

template

Type: String Default value: undefined

Note: This option is only valid at the block level.

A template string to be used for the replacement block.

Something went wrong with that request. Please try again.