Ruby on rails,标记解释器,在运行时提供自定义标签?对于表单,而不是视图

时间:2021-04-08 20:46:43

Site for writers and readers, both groups will be non-technical users (writers will be familiar with BBCode already, but I can choose other markup). Writers will write guides using markup tags to embodied info. Readers will be presented with parsed text. Tags will be expanded to some info.

对于作者和读者的网站,这两个群体都是非技术用户(作者已经熟悉BBCode,但我可以选择其他标记)。作家将使用标记标记向具体信息编写指南。读者将看到解析的文本。标签将扩展为一些信息。

Number of tags needed as well as info tied to particular tag will change. So they can not be hard-coded.

所需的标签数量以及与特定标签相关的信息将发生变化。所以它们不能被硬编码。

I'm looking for any interpreter that can use tags provided at run time, for my next Ruby on rails app. Anyone know such?

我正在寻找任何可以使用运行时提供的标签的解释器,用于我的下一个Ruby on rails应用程序。谁知道这样的?

Edit: Yeah. I'm not looking for views markup, but for forms textarea markup to be used by website users (to format their guides, but I do need ONE markup for formatting, and embedding info).

编辑:是的。我不是在寻找视图标记,但是对于网站用户使用的表单textarea标记(格式化他们的指南,但我确实需要一个标记来格式化和嵌入信息)。

1 个解决方案

#1


1  

Based on my current understanding of your needs, I recommend mustache. This is described as a "logic-less" template processor. It doesn't have programming logic, simply run-time replacements.

根据我目前对您需求的了解,我推荐胡子。这被描述为“无逻辑”模板处理器。它没有编程逻辑,只是运行时替换。

Here's one way to use it (from the github readme)

这是使用它的一种方法(来自github自述文件)

Given this template (winner.mustache):

鉴于此模板(winner.mustache):

Hello {{name}}
You have just won {{value}} bucks!

We can fill in the values at will:

我们可以随意填写价值:

view = Winner.new
view[:name] = 'George'
view[:value] = 100
view.render

Which returns:

哪个回报:

Hello George
You have just won 100 bucks!

#1


1  

Based on my current understanding of your needs, I recommend mustache. This is described as a "logic-less" template processor. It doesn't have programming logic, simply run-time replacements.

根据我目前对您需求的了解,我推荐胡子。这被描述为“无逻辑”模板处理器。它没有编程逻辑,只是运行时替换。

Here's one way to use it (from the github readme)

这是使用它的一种方法(来自github自述文件)

Given this template (winner.mustache):

鉴于此模板(winner.mustache):

Hello {{name}}
You have just won {{value}} bucks!

We can fill in the values at will:

我们可以随意填写价值:

view = Winner.new
view[:name] = 'George'
view[:value] = 100
view.render

Which returns:

哪个回报:

Hello George
You have just won 100 bucks!