searls/jasmine-maven-plugin — pull request #124 by klieber (2012-11-17 04:46:50+00:00)
Title: Topic/template fields

This pull request makes the RequireJsSpecRunnerHtmlGenerator and other customizations introduced by the require.js changes unnecessary. This is done simply by changing the DefaultSpecRunnerHtmlGenerator so that it provides more template variables. Then we can build the a spec runner template that supports require.js using the DefaultSpecRunnerHtmlGenerator.

The specRunnerTemplate configuration parameter is still available, except now it is an enum and it is used simply to choose pre-built templates. You can take a look at the enum here: [SpecRunnerTemplate.java](https://github.com/klieber/jasmine-maven-plugin/blob/e5aa554a9a3015c9faff53afd3781d6bf2918892/src/main/java/com/github/searls/jasmine/runner/SpecRunnerTemplate.java)

Here is an example of using the REQUIRE_JS built in template:

```xml

com.github.searls
jasmine-maven-plugin
${jasmine-maven-plugin.version}
true

test

REQUIRE_JS

lib/require.js

```

And the template looks like this:
```html

Jasmine Spec Runner

$cssDependencies$
$javascriptDependencies$
$preloadScriptTags$

```

This change not only simplifies the code quite a bit but it also gives users the power to truly customize their templates how they wish. For instance, I prefer to use [testr](https://github.com/mattfysh/testr.js) for testing require.js modules rather than wrapping each test in a `define` so the built in template doesn't work for me. With this pull request now I can just use this configuration:

```

com.github.searls
jasmine-maven-plugin
${jasmine-maven-plugin.version}
true

test

lib/require.js
lib/testr.js

src/test/config/testr_runner.htmltemplate

```

My testr_runner.htmltemplate will look something like this:
```html

Jasmine Spec Runner

$cssDependencies$
$javascriptDependencies$
$preloadScriptTags$

```

The best part of this change is that it no longer is the plugin's responsibility to support all the possible frameworks one might be using. In fact, we really wouldn't even have to keep a built-in REQUIRE_JS spec runner template in the plugin. You could simply just provide a wiki page with example templates for using different frameworks.