markdown 将嵌入式json数据中的换行符和html代码传递给模式实验室

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 将嵌入式json数据中的换行符和html代码传递给模式实验室相关的知识,希望对你有一定的参考价值。

Go ahead and use html code such as `<br>` in your variable and then in the included twig template, call that variable with the raw filter, eg:

```twig
{% embed "00-atoms/01-text/08-address" with 
  {'address': "201 Eddy St, <br>
  San Francisco CA 94102"
  } %}
{% endembed %} 
```

in 00-atoms/01-text/08-address:
```twig
 {{ address | raw }}
```

Alternately, if all you need is line breaks, just make sure that the div into which you are passing the data has the styling: `white-space: pre-line;` and then put line breaks right in the data, eg:

```twig
{% embed "00-atoms/01-text/08-address" with 
  {'address': "201 Eddy St,
  San Francisco CA 94102"
  } %}
{% endembed %} 
```

以上是关于markdown 将嵌入式json数据中的换行符和html代码传递给模式实验室的主要内容,如果未能解决你的问题,请参考以下文章