0

If I'm creating a view in Express and I'm using Hogan for server-side templating, how can I include templates for Angular to consume as well?

For example, the following is a simple Express view with Angular's 'hello world' included:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
</head>
<body ng-app>

<label for="">Message: <input type="text" ng-model="message"/></label>
<p>{{message}}</p>

</body>
</html>

How do I prevent {{message}} from being parsed by the Express on the server?

scniro
  • 16,844
  • 8
  • 62
  • 106
Bryce Johnson
  • 6,689
  • 6
  • 40
  • 51

1 Answers1

1

You would probably have to override the delimiters Hogan uses by doing:

Hogan.compile(text, {delimiters: '<% %>'});

But, TBH, it doesn't make much sense to use both server side and client side templating

Community
  • 1
  • 1
dave
  • 62,300
  • 5
  • 72
  • 93
  • I was just starting to think that (doesn't make much sense)... Two problems : 1) I didn't know you could disable Express's templating and 2) I was thinking I needed to use Angular's templating, without realizing there are plenty of ways around it (ngValue, ngBind). Thanks for your help! – Bryce Johnson Jul 08 '14 at 02:14