CSR
CSR

Reputation: 820

Grails Dynamic links in static resources

To link a controller / action, g:createLink is useful. But if the resource is static like javascript how to create dynamic link? As these pages not parsed in tomcat container as gsp pages, is there any solution instead of specifying statically.

Upvotes: 0

Views: 444

Answers (2)

Ashish Joseph
Ashish Joseph

Reputation: 1153

Make the file extension to "filenName.fileType.gsp". For example, if you want to use resource tag inside "main.css" file, you should rename it to "main.css.gsp".

Note : You might loose IDE auto-complete after this..

Upvotes: 1

micha
micha

Reputation: 49572

I think the resource tag is what you are looking for:

// generates "/shop/css/main.css"
<g:resource dir="css" file="main.css" />

// generates "http://portal.mygreatsite.com/css/main.css" 
<g:resource dir="css" file="main.css" absolute="true" />

// generates "http://admin.mygreatsite.com/css/main.css" 
<g:resource dir="css" file="main.css" base="http://admin.mygreatsite.com"/>

(copied from the documentation page)

Upvotes: 0

Related Questions