简体   繁体   English

如何防止Express分析Angular模板?

[英]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.

相关问题 我怎样才能阻止他们输入地址? (表示) - How can i prevent them from entering to an address? (express) Express会话的行为有所不同:如何防止刷新页面后破坏会话? - Express sessions behaving differently: How can I prevent my session from being destroyed after a page refresh? 如何将模板从html文件加载到Angular应用中? - How can I load templates from an html file into my Angular app? 我该怎么用 <html> Angular2中的模板? - How can I use <html> templates in Angular2? 当我将属性作为字符串插入时,如何防止Angle进行数学运算 - How can I prevent angular from doing math when i insert an attribute as a string Javascript和模板位于并行文件夹中,如何同时提供快递服务? - Javascript and templates are in parallel folders how can I serve up both in express? 我可以在Angular 2中使用标签模板吗? - Can i use tags templates in Angular 2? 如何在编辑时阻止Angular重新排序列表? - How can I prevent Angular from re-sorting my list while editing? 如何在ng-if评估之前阻止Angular渲染和显示页面? - How can I prevent Angular from rendering and displaying a page before ng-if evaluation? 如何防止 angular 在生产模式下删除查询参数? - How can I prevent angular from removing query parameters on production mode?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM