We're writing a grails (Grails 2.1.1) project where, for some of our views, we want to use markdown instead of gsp files.
At the moment we can do this using the markdown plugin in a special layout. This allows us to render markdown views like so:
render(layout: 'docs', view: 'markdown')
However, this requires the markdown page to have a .gsp extension, when, for practical reasons, we need it to have a .md extension.
Does anyone know a better way to use markdown as a grails view? It would be great if we can avoid using the .gsp extension.
You're not going to be able to without some heavy modifications. The distributed GrailsViewResolver is hard-tied to .gsp and .jsp extensions.
See grails-core on github for verification.
You might be able to fashion your own Ant task to hook it into the Compile cycle of your Grails application so that, at a minimum, you can compile your *.md files through the GroovyPageCompiler.
That process might look something like this (though not exactly, since I am relying on the plugin's taglib to do the rendering in this case, for simplicity).
But this doesn't solve all of your problems. You would also need to register a new view resolver, and to do that you would inevitably go down the road of rewriting the GrailsDispatcherServlet.
It sounds like your solution of storing the files in the conf directory might be your best (although dirty) bet for now. Maybe somebody will take the time to allow for configurable GSP file extensions in the future, and that might solve your problem down the road.
I hope you find some of this information useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With