Home Create Layout Template Velocity
Reply: 0

Create Layout Template Velocity

Max Günther
1#
Max Günther Published in 2018-01-12 21:10:28Z

i would like to create a default template which contains all the layout stuff like head and body of the html page. But im cant get it to work. I searched for it, but all the solutions that had been used, dont work for me!

My Controller:

path("/", () -> {
            get("", (req, res) -> {
                return new ModelAndView(new HashMap<>(), "views/menu.vm");
            }, velocityTemplateEngine);
        });

main.vm:

#macro(mainLayout)
<html>
<head>
   <script></script>
</head>
<body style="background-color: #2a2730">
<div class="content-container">
    <p>$!bodyContent</p>
</div>
</body>
</html>
#end

menu.vm

#@mainLayout()
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Kicker</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="/">Home</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       role="button" aria-haspopup="true" aria-expanded="false">Player <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="/player/list">Players list</a></li>
                        <li><a href="/player/new">New Player</a></li>
                        <li role="separator" class="divider"></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       role="button" aria-haspopup="true" aria-expanded="false">Match <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="/match/list">Match list</a></li>
                        <li><a href="/match/new">New Match</a></li>
                        <li role="separator" class="divider"></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       role="button" aria-haspopup="true" aria-expanded="false">Season <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="/season/list">Season list</a></li>
                        <li><a href="/season/new">New Season</a></li>
                        <li role="separator" class="divider"></li>
                    </ul>
                </li>
                <li><a href="/match/dashboard">Dashboard</a></li>
                <li><a href="/stats">Statistics</a></li>
            </ul>
        </div>
    </div>
</nav>
#end

For any help I would be very happy

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307563 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO