【发布时间】:2019-02-11 22:43:22
【问题描述】:
我需要在我的网站上保存“采购合同”类型的报告。我正在使用Sinatra 使用erb 文件来传递内容。当人们注册各种项目时,我想通过电子邮件发送当前报告(版本会更改)。
我想我可以将它以某种格式存储在数据库或外部文件中,这样我就可以两者都做:
- 将其导入
erb文件以在网络上展示 - 在电子邮件中使用它,以便以文本格式阅读
所以基本上我需要尽可能基本的格式,但它必须翻译成HTML (erb) 和文本。
我对这个文件的格式有哪些选择?我怎样才能把它翻译成 HTML?我看过markdown,我发现gems 不是很漂亮,我发现它翻译成文本。看到它需要纯文本以及HTML,我有点不知道如何完成这项工作。
文件片段
Privacy Policy
Updated Feb 20, 2019
Website.com (“Website”) is a private business. In this Privacy Statement the terms “we” and “our” refer to Website. This Privacy Statement explains Website’s practices regarding personal information of our users and visitors to this website (the “Website”), as well as those who have transactions with us through telephone, Internet, faxes and other means of communications.
Website’s Commitment to Privacy
At Website, we are committed to respecting the privacy of our members and our Website visitors. For that reason we have taken, and will continue to take, measures to help protect the privacy of personal information held by us.
This Privacy Statement provides you with details regarding: (1) how and why we collect personal information; (2) what we do with that information; (3) the steps that we take to help ensure that access to that information is secure; (4) how you can access personal information pertaining to you; and (5) who you should contact if you have questions and concerns about our policies or practices.
【问题讨论】:
-
有点不清楚你在问什么,但肯定有可能。看看sinatra partial。
-
@iain 是的,我将重组问题。
-
你见过docs for ERB吗?使用它,您应该能够从任何地方渲染模板。还可以阅读Sinatra README 的视图/模板部分。如果在那之后您仍然不清楚,请大声喊叫,我会在下面写更长的内容。
-
@iain 是的,我有。使用
erb已经有一段时间了。我有一个File.read(filepath)输出,但它的格式不正确(privacy.txt)。我经常阅读 Sinatra README,但大部分内容仍然令人困惑。 -
我已经把答案放在下面了,如果您有任何问题,请添加一些 cmets,我会尝试对其进行扩展。