合并angular2模板时HTML中的EOF字符? [英] EOF chars in html when merging angular2 templates?

查看:88
本文介绍了合并angular2模板时HTML中的EOF字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个nodeJS应用程序,该应用程序读取目录中的所有 .md 文件,然后使用

我不确定这是否是因为要合并的单个文件中的EOF字符出现了,或者我的 {转义有问题,因为错误消息也暗示了这一点.

错误底部引用的代码段如下所示:

 < code> css{{'页 {背景颜色:白色;字号:17;}文本域 {保证金:10;填充:10;}图像 {上边距:20;左边距:0;右边距:0;底边距:80;}按钮 {保证金:10;填充:10;}'}}</code> 

NB: chapterComponent @ 1805:6 是文件的结尾

解决方案

更新

我认为您需要将每个 {替换为 {{'{'}} ,将} 替换为 {{}'}} 并显示错误消息.

根据评论无效

尝试反引号而不是单引号.单引号仅适用于单行字符串.

 < code> css{{`页 {背景颜色:白色;字号:17;}文本域 {保证金:10;填充:10;}图像 {上边距:20;左边距:0;右边距:0;底边距:80;}按钮 {保证金:10;填充:10;}`}}</code> 

I have a nodeJS application which reads all the .md files in a directory and then renders their contents as HTML using marked. I am then using the result as an Angular2 template.

However, I am now getting a console error like this:

Unhandled Promise rejection: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("width="760" height="1300" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
</div>[ERROR ->]"): chapterComponent@1805:6
Invalid ICU message. Missing '}'. ("

<code>css
[ERROR ->]{{'
Page {
    background-color: white;
"): chapterComponent@395:0 ; Zone: <root> ; Task: Promise.then ; Value: BaseException {message: "Template parse errors:↵Unexpected character "EOF" …ckground-color: white;↵"): chapterComponent@395:0", stack: "Error: Template parse errors:↵Unexpected character…st:3000/node_modules/zone.js/dist/zone.js:356:38)"}

I am not sure if this is because the EOF chars from the individual files being merged are coming across, or there is an issue with my { escaping as the error message is alluding too.

The snippet being referenced at the bottom of the error looks like this:

<code>css
{{'
Page {
    background-color: white;
    font-size: 17;
}
TextField {
    margin: 10;
    padding: 10;
}
Image {
    margin-top: 20;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 80;
}
Button {
    margin: 10;
    padding: 10;
}
'}}</code>

NB: chapterComponent@1805:6 is the end of the file

解决方案

update

I think you need to replace each single { by {{'{'}} and } by {{'}'}} as the error message says.

doesn't work according to the comment

Try a backtick instead of a single quote. Single quote is only for single line strings.

<code>css
{{`
Page {
    background-color: white;
    font-size: 17;
}
TextField {
    margin: 10;
    padding: 10;
}
Image {
    margin-top: 20;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 80;
}
Button {
    margin: 10;
    padding: 10;
}
`}}</code>

这篇关于合并angular2模板时HTML中的EOF字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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