[英]How can I prevent Express from parsing Angular templates?
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? 如果我正在Express中创建视图,并且正在使用Hogan进行服务器端模板制作,那么如何包括Angular也可以使用的模板?
For example, the following is a simple Express view with Angular's 'hello world' included: 例如,以下是包含Angular的“ hello world”的简单Express视图:
<!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? 如何防止服务器上的Express对
{{message}}
进行解析?
You would probably have to override the delimiters Hogan uses by doing: 您可能需要通过执行以下操作来覆盖Hogan使用的分隔符:
Hogan.compile(text, {delimiters: '<% %>'});
But, TBH, it doesn't make much sense to use both server side and client side templating 但是,TBH, 同时使用服务器端和客户端模板并没有多大意义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.