Hi I am trying to use mustache templates in playframework 2. So my index.scala.html looks something like
@import com.feth.play.module.pa.views.html._
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<title>Test</title>
<script data-main="@routes.Assets.at("javascripts/main.js")" src="@routes.Assets.at("javascripts/require.js")"></script>
<body>
<header>
</header>
</body>
</html>
I am inserting the header via a backbone view.
define(['use!jquery', 'use!underscore', 'use!backbone', 'text!templates/View.HeaderView.html',
'bootstrap', 'bootstrap-dropdown'],
function($, _, Backbone,headerViewTemplate) {
return Backbone.View.extend({
el: $('header'),
events: {
},
initialize: function(options) {
console.log('headerview init');
this.template = headerViewTemplate;
}
}
The View.HeaderView.Html is defined as follows
<div id="auth-status">
@currentAuth() { auth =>
@if(auth != null) {
<div class="btn-group pull-right" id="auth-loggedin" style="display:auto">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-user" id="auth-displayname"></i> Welcome
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">Settings</a></li>
<li class="divider"></li>
<li><a href="@com.feth.play.module.pa.controllers.routes.Authenticate.logout" id="auth-logoutlink">Sign Out</a></li>
</ul>
</div>
}
@if(auth == null) {
@forProviders() { p =>
<div class="btn pull-right" id="auth-loggedout">
<a href="@p.getUrl()" id="auth-loginlink">
<i class="icon-user"></i> Login With Facebook</a>
</div>
}
}
}
</div>
So the issue I am having is the scala templates shows up as regular text not scala code. If I place the code in index.scala.html it works.
Help!!!
Your View.HeaderView.Html
file is not detected as scala code and is not executed/compiled.
views
package of your application. .scala.html
extension. Otherwise the compiler will not find it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.