gpt4 book ai didi

javascript - 将 anchor 添加到 javascript 数组以与 handlebars.js 一起使用

转载 作者:行者123 更新时间:2023-11-30 16:53:15 25 4
gpt4 key购买 nike

我在 javascript 变量中存储了大量数组。我的数组之一的示例是:

{
index: 6,
template: 2,
title: "Innovation Center",
shortname: 'innov',
projectActive: 'true',
subtitle: "Construct",
location: "alaska",
x: 1304,
y: 610,
image1: "img/watt.jpg",
image2: "img/image_2.jpg",
bgImage: "img/bgImage.jpg",
headline1: "Catapulting Ideas to Reality",
paragraph1: "A long paragraph of text",
headline2: "The Future Won't Wait, and Neither Will We",
paragraph2: "This is a long paragraph of text",
listTitle: "Innovative resources include: ",
listItems: [
{ item: "Visual analytics" },
{ item: "Communication skills development" },
]
},

这是使用 handlebars.js 打印成 HTML 的,如下所示:

<div class="header" style="background-image: url( {{ bgImage }} );" >
<div class="container">
<div class="col-sm-12">
<h1> {{ title }} </h1>
<h4> {{ subtitle }} </h4>
</div>
</div>
</div>

<div class="container">
<div class="row paragraph1">
<div class="col-sm-6" >
<div class="image1" style="background-image: url( {{image1}} );">
</div>
</div>
<div class="col-sm-6">
<h2> {{ headline1 }}</h2>
<p> {{ paragraph1 }} </p>
</div>
</div>

我的问题是如何使用 html 将一些文本包装在“段落”键值中。所以我想做的是:

paragraph1: "A long <a href="google.com">paragraph</a> of text",

但这只是在页面上吐出代码。任何帮助将不胜感激。

最佳答案

尝试使用三重存储:

{{{ paragraph1 }}}

http://handlebarsjs.com/#html-escaping

关于javascript - 将 anchor 添加到 javascript 数组以与 handlebars.js 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30174162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com