html - 合并 angular2 模板时 html 中的 EOF 字符?

标签 html node.js angular

我有一个 nodeJS 应用程序,它读取目录中的所有 .md 文件,然后使用 marked 将其内容呈现为 HTML 。然后我将结果用作 Angular2 模板。

但是,我现在收到如下控制台错误:

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)"}

enter image description here

我不确定这是否是因为遇到了正在合并的各个文件中的 EOF 字符,或者我的 { 转义存在问题,因为错误消息也暗示了这一点。

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

<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>

注意:chapterComponent@1805:6 是文件末尾

最佳答案

更新

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

根据评论不起作用

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

<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>

关于html - 合并 angular2 模板时 html 中的 EOF 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39077960/

相关文章:

css - 在 html5 语义标签周围包装一个 div?

html - 将结束引号左对齐?

mysql - 4 字节表情符号在 MYSQL 中被不适本地保存,忽略字符集,而在 google 数据存储中则正常

angular - OAuth2认证后获取角色类型

html - 如何使用 CSS 创建带边框的透明三 Angular 形?

jquery - 如何使2个div标签彼此相邻

JavaScript 术语 : do I (call/invoke/execute) a function?

node.js - Node ssh2 shell 无法在远程计算机上运行 apt-get install

typescript - 使用 Angular2 : Unexpected anonymous System. 注册调用进行 karma 测试

angular - Storybook 给出 "Can' t 解决 AppComponent 的所有参数“Angular 库中的错误