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

Plugin attempts to resolve JS variables with the '$' character in name #4

Open
imjayson opened this issue May 22, 2014 · 4 comments
Open

Comments

@imjayson
Copy link

tried to render an angular JS file and hit error when plugin attempts to resolve non-grails variables like '$routeProvider'.

$ signs are quite common in frameworks like angular and jquery. need a way to escape these dollar signs or only render items surrounded by ${}.

Error |
2014-05-22 17:02:28,233 [http-bio-8080-exec-10] ERROR errors.GrailsExceptionResolver - MissingPropertyException occurred when processing request: [GET] /FRMS/assets/angular/app.js - parameters:
compile: false
No such property: routeProvider for class: SimpleTemplateScript5. Stacktrace follows:
Message: No such property: routeProvider for class: SimpleTemplateScript5
Line | Method
->> 1 | run in SimpleTemplateScript5


| 35 | process in asset.pipeline.groovytemplate.GroovyTemplateProcessor
| 27 | processedStream . . in asset.pipeline.AbstractAssetFile
| 112 | fileContents in asset.pipeline.DirectiveProcessor
| 62 | serveUncompiledAsset in asset.pipeline.AssetProcessorService
| 24 | index in asset.pipeline.AssetsController
| 198 | doFilter . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 60 | doFilter . . . . . . in asset.pipeline.AssetPipelineFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread

@tednaleid
Copy link
Owner

Yeah, this is an unfortunate side-effect of using the groovy.text.SimpleTemplateEngine for parsing files. It assumes that anything starting with a $ must be a groovy expression. I've looked a bit at extending it, but it's pretty nasty code from an extensibility standpoint (private inner classes that also have private methods, ugh).

How I've used the plugin is that I tend to have a few relatively small js-gtpl plain JS files that have all of my groovy template stuff in it (to import enums and get config values). Then concatenate that with the other files with the asset-pipeline plugin. Those are the files that use things like $http, $routeProvider, $, etc, but those just have .js extensions and don't use this plugin.

@imjayson
Copy link
Author

yup that's a good way to use the plugin, will do that.

thanks!

@bioform
Copy link

bioform commented Sep 25, 2014

I've just take a look in to groovy 2.3.0 SimpleTemplateEngine class... The most part of code is located in "private static class SimpleTemplate" so I see only one way to fix it - just copy/paste it(SimpleTemplateEngine) and use it insetead default one ))))

@sandhyamurugesan
Copy link

Could you please tell how to concatenate the small js-gtpl groovy expression files in the .js file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants