Hello i have something very simple:
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="{{adminUrl}}/assets/css/bootstrap/bootstrap-responsive.min.css">
<link rel="stylesheet" href="{{adminUrl}}/assets/css/bootstrap/bootstrap.min.css">
<script type="text/javascript" src="{{adminUrl}}/assets/js/vendors/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="{{adminUrl}}/assets/js/bootstrap/bootstrap.min.js"></script>
</head>
<body>
<div style="padding: 20px; background: #fafafa; border-bottom: solid 1px #eee">
<a href="{{adminUrl}}/users/" class="btn">users list/no paging</a>
<a href="{{adminUrl}}/create/" class="btn">create new user</a>
</div>
<h1>List data:</h1>
<ol>
{{#each data}}
<li>
<div><a href="{{adminUrl}}/details/{{id}}"><b>{{username}} - {{id}}</b></a></div>
{{email}}
<div> </div>
</li>
{{/each}}
</ol>
</body>
</html>
This is an expressjs view that uses handlebars. 'adminUrl' is in app.locals.
app.locals({
adminUrl: _config.rootUrl
});
In the css, js and a href links outside the {{#each works just fine, but in the {{#each... does not. How can i fix it to work?
try {{../adminUrl}}
within your {{#each}}
block as I believe handlebars will change the context to be the current member of data
and thus you need ..
to access the parent context.