Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an option to override the default SpecRunner template file #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ This object is `JSON.stringify()`-ed ( **support serialize Function object** ) i

If `requireConfigFile` is specified then it will be loaded first and the settings specified by this directive will be deep-merged onto those.

### templateOptions.specRunnerTemplate
Type: `String`

If you wish to override the template version of the SpecRunner.html that is built out (for customizing), then you can provide the path for this. If you wish to alter the template, you can create a copy from [here](https://github.com/cloudchen/grunt-template-jasmine-requirejs/blob/master/src/templates/jasmine-requirejs.html). If `specRunnerTemplate` is provided and the file exists, it uses this file, otherwise it falls back to the default built in template.

## Sample usage

Expand Down
4 changes: 3 additions & 1 deletion src/template-jasmine-requirejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ exports.process = function(grunt, task, context) {
// update relative path of .grunt folder to the location of spec runner
context.temp = path.relative(path.dirname(context.outfile),
context.temp);

if (context.options.specRunnerTemplate && grunt.file.exists(context.options.specRunnerTemplate)) {
template = context.options.specRunnerTemplate;
}
var source = grunt.file.read(template);
return grunt.util._.template(source, context);
};