craigburke / karma-gradle

Gradle Plugin for Running tests with Karma
Other
21 stars 11 forks source link

added support to js functions in build.gradle #6

Closed fmillone closed 8 years ago

fmillone commented 8 years ago

example

 ngHtml2JsPreprocessor = [
        // the name of the Angular module to create
        moduleName: "templates",
        cacheIdFromPath: "function(filepath) { return filepath.replace('grails-app/assets/javascripts', '').replace('/templates/', '/').replace('.tpl.html','.html') ; }"
    ]

generates =>

"ngHtml2JsPreprocessor": {
            "moduleName": "temoplates", "cacheIdFromPath": function (filepath) {
                return filepath.replace('grails-app/assets/javascripts', '').replace('/templates/', '/').replace('.tpl.html', '.html');
            }
craigburke commented 8 years ago

Hi @frabmax3!

I'm looking at this now. Thanks for the PR.

craigburke commented 8 years ago

@frabmax3 I definitely see the need you're addressing with this PR. I'd love to add support for this. I have some concerns about bringing in the json-lib dependency (I'm just not familiar with it and it doesn't seem to be actively maintained).

I think it's a great idea to support functions but we can probably accomplish this without adding additional dependencies. I'd like to play around with that and maybe you can take a look at what I come up with.

fmillone commented 8 years ago

@craigburke You are right, I never thought about that library been unmaintained. Before adding it I tried to make it work with the jsonBuilder without success.

I also found another solution with this library https://github.com/stleary/JSON-java, by inheriting from JSONString. Maybe some similar solution can be accomplished with the jsonBuilder, but I have no clue about how It works internally.