简体   繁体   中英

Ruby on rails, markup interpreter with custom tags provided on runtime? For forms, not views

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.

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?

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).

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)

Given this template ( 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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