Search code examples
eclipsegrailsgspsts-springsourcetoolsuite

Include .js file in All Gsp file in STS (Eclipse) IDE?


is there any way to include a file in all gsp file header ? i want to include a file

<g:javascript src="hotkey.js"/> 

in all Gsp files heade part. i'm using STS (SpringSource Tool Suite).


Solution

  • If you include your .js files in main.gsp then it will automatically be included in all gsps with the tag <meta name="layout" content="main" /> in the <head>. Example gsp head below:

       <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'transactionRecord.label', default: 'TransactionRecord')}" />
        <title><g:message code="default.create.label" args="[entityName]" /></title>
    </head>
    

    The main layout is automatically included in all gsps generated by the scaffolding create commands.