简体   繁体   English

Kostache:\\ n或Enter键不会转到下一行

[英]Kostache: \n or enter key does not go to next line

I am using Kostache, Kohana and CKEditor for my website. 我在我的网站上使用Kostache,Kohana和CKEditor。 In the database some of the tables are readonly, the content is coming from some other site. 在数据库中,某些表是只读的,其内容来自其他站点。 My issue is that, I need to show a new line wherever enter is given in the content. 我的问题是,无论内容中输入的是什么,我都需要显示一个新行。 In current situation, all content comes in one line without any break 在当前情况下,所有内容都统一显示在一行中

example: Input/Expected Output: "This is the text. 示例:输入/预期输出:“这是文本。

This is the new Text." 这是新的文本。”

Current Output: "This is the text. This is the new Text." 当前输出:“这是文本。这是新文本。”

Is there any solution for this.. 有没有解决的办法。

If you are storing the new line character in the database, on the frontend side of things, you can use nl2br() to convert the new lines to break tags. 如果要将换行符存储在数据库中,则在前端,可以使用nl2br()将换行符转换为break标记。 Then with Kostache, you have to tell it to allow html in the variable (ie {{& content_var}}). 然后使用Kostache,您必须告诉它允许在变量中使用html(即{{&content_var}})。

If you have no new line characters stored with the character, you could create a much uglier solution, like using replacing period with a period and break tag, although I do not recommend that solution unless you absolutely have no other option. 如果没有与该字符一起存储的换行符,则可以创建一个更丑陋的解决方案,例如使用以句点和break标记替换period,但是除非绝对没有其他选择,否则我不建议您使用该解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM