如何更改Handlebars语法以区别Angular模板语法? [英] How can I change the Handlebars syntax to differentiate from the Angular template syntax?

查看:106
本文介绍了如何更改Handlebars语法以区别Angular模板语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Handlebars对Angular应用程序的动态模板进行客户端预处理。我需要Handlebars进程渲染一些包含 {{this notation}} 的角度标记,这是针对角模板引擎而非Handlebars模板引擎的。

  {{这是一个包含{{Angular表达式}}的Handlebars表达式...}} 

这里是否有区分Handlebars和Angular的双花括号符号的语法?我不想更改Angular的语法,因为我有大量依赖于该语法的代码。我可以适应Handlebars语法吗?

解决方案

Igor Raush的答案中的语法特定于小胡子。 Handlebars不支持此功能。



Handlebars确实允许您在大括号之前使用反斜线和单斜线。但是由于某些原因,你不会在他们的文档中找到它。



这并不能解决问题中嵌套表达式的边界情况,但它是我能够解决的最接近的问题这个问题可能对面临类似问题的人有用。



以下是一个例子:

< div> {{thisWillBeProcessedByHandlebars}}< / div> $ b

< div> \ {{ThisWontBeProcessedByHandlebars}}< / div>


I'm using Handlebars to do client side preprocessing of dynamic templates for an Angular app. I require the Handlebars process to render some Angular mark up that contains {{ this notation }} that is for the angular templating engine as opposed to the Handlebars templating engine.

{{This is a Handlebars expression that contains an {{Angular expression}}...}}

Is there a syntax for differentiating between Handlebars and Angular's double curly brace notation here? I don't want to change the syntax for Angular as I have a large amount of code dependent on that syntax. Can I adapt the Handlebars syntax?

解决方案

The syntax in Igor Raush's answer is specific to Moustache. Handlebars doesn't support this functionality.

Handlebars does allow you to escape a single line with and backslash before the curly braces. But you wont find this in their documentation for some reason.

This doesn't address the edge case of nested expressions in the question but is the closest I could get to solving the issue and might prove useful to people facing a similar problem.

Here is an example:

<div>{{thisWillBeProcessedByHandlebars}}</div>

<div>\{{ThisWontBeProcessedByHandlebars}}</div>

这篇关于如何更改Handlebars语法以区别Angular模板语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆