0

The HTML spat out from a view has a lot of empty spaces and empty lines.

What and where do I need to type to make grails not to generate the empty spaces or empty lines?

Thanks!

Just for example. I have an empty domain. And then use generate-all to create all the controller and view. This is the HTML spat out from the index.gsp. If you use your mouse to highlight the HTML, you will see a lot of empty spaces.


<!doctype html>
<html lang="en" class="no-js">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>
        NewGroovyClass List
    </title>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <link rel="icon" type="image/x-ico" href="/assets/favicon.ico"/>

    <link rel="stylesheet" href="/assets/bootstrap.css?compile=false" />
<link rel="stylesheet" href="/assets/grails.css?compile=false" />
<link rel="stylesheet" href="/assets/main.css?compile=false" />
<link rel="stylesheet" href="/assets/mobile.css?compile=false" />
<link rel="stylesheet" href="/assets/application.css?compile=false" />


    
        <meta name="layout" content="main"/>
        
        
    
</head>

<body>

<nav class="navbar navbar-expand-lg navbar-dark navbar-static-top" role="navigation">
    <a class="navbar-brand" href="/#"><img src="/assets/grails.svg" alt="Grails Logo"/></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" aria-expanded="false" style="height: 0.8px;" id="navbarContent">
        <ul class="nav navbar-nav ml-auto">
            
        </ul>
    </div>

</nav>


        <a href="#list-newGroovyClass" class="skip" tabindex="-1">Skip to content&hellip;</a>
        <div class="nav" role="navigation">
            <ul>
                <li><a class="home" href="/">Home</a></li>
                <li><a href="/newGroovyClass/create" class="create">New NewGroovyClass</a></li>
            </ul>
        </div>
        <div id="list-newGroovyClass" class="content scaffold-list" role="main">
            <h1>NewGroovyClass List</h1>
            
            

            <div class="pagination">
                
            </div>
        </div>
    

<div class="footer row" role="contentinfo">
    <div class="col">
        <a href="http://guides.grails.org" target="_blank">
            <img src="/assets/advancedgrails.svg" alt="Grails Guides" class="float-left"/>
        </a>
        <strong class="centered"><a href="http://guides.grails.org" target="_blank">Grails Guides</a></strong>
        <p>Building your first Grails app? Looking to add security, or create a Single-Page-App? Check out the <a href="http://guides.grails.org" target="_blank">Grails Guides</a> for step-by-step tutorials.</p>

    </div>
    <div class="col">
        <a href="http://docs.grails.org" target="_blank">
            <img src="/assets/documentation.svg" alt="Grails Documentation" class="float-left"/>
        </a>
        <strong class="centered"><a href="http://docs.grails.org" target="_blank">Documentation</a></strong>
        <p>Ready to dig in? You can find in-depth documentation for all the features of Grails in the <a href="http://docs.grails.org" target="_blank">User Guide</a>.</p>

    </div>

    <div class="col">
        <a href="https://grails-slack.cfapps.io" target="_blank">
            <img src="/assets/slack.svg" alt="Grails Slack" class="float-left"/>
        </a>
        <strong class="centered"><a href="https://grails-slack.cfapps.io" target="_blank">Join the Community</a></strong>
        <p>Get feedback and share your experience with other Grails developers in the community <a href="https://grails-slack.cfapps.io" target="_blank">Slack channel</a>.</p>
    </div>
</div>


<div id="spinner" class="spinner" style="display:none;">
    Loading&hellip;
</div>

<script type="text/javascript" src="/assets/jquery-3.3.1.min.js?compile=false" ></script>
<script type="text/javascript" src="/assets/bootstrap.js?compile=false" ></script>
<script type="text/javascript" src="/assets/popper.min.js?compile=false" ></script>
<script type="text/javascript" src="/assets/application.js?compile=false" ></script>


</body>
</html>

tom6502
  • 180
  • 7
  • "The HTML spat out from a view has a lot of empty spaces and empty lines." - You get to control the content of the response. "What and where do I need to type to make grails not to generate the empty spaces or empty lines?" - Can you show an example of some code that generates unwanted empty lines? – Jeff Scott Brown Oct 23 '21 at 17:40
  • I edited my question to copy and paste the HTML to my question. – tom6502 Oct 23 '21 at 18:44
  • I see the question has been updated with more info. I think you are asking the same question as https://stackoverflow.com/questions/18735312/render-gsp-view-as-compact-html-file. – Jeff Scott Brown Oct 24 '21 at 14:40
  • The question they answered were 3 years old. They are all outdated. None of the answers works no more. – tom6502 Oct 24 '21 at 23:43
  • Agreed. I was pointing out that I think this question is a duplicate. I wasn't making a comment about the answers. – Jeff Scott Brown Oct 25 '21 at 15:59

0 Answers0