Andy
Andy

Reputation: 335

How can we implement Jeff Eaton's custom tags strategy in Ruby?

I distinctly recognise the problem described in Jeff Eaton's article The Battle for the Body Field on A List Apart. That of handing clients a CMS that strikes a balance between conceptual simplicity in editing content, and flexibility in the flow and structure of that content. Whilst generating clean, forward-compatible code and responsive layouts.

I'm now convinced that some sort of custom tags are the solution to this problem. Even if they are wrapped in a WYSIWYG editor.

I'd like to keep preprocessing server-side until web-components are more widely, natively supported. And I favour Ruby/Rails for development.

So what libraries are available that would help with preprocessing and expanding custom XML or HTML tags in this way?

XSLT seems too limited. And Radius is perhaps a contender, though it doesn't appear to still be in active development.

Upvotes: 0

Views: 48

Answers (1)

Mohamad
Mohamad

Reputation: 35349

I tend to favour markdown because it's extensible and acts as a subgroup of HTML. In Ruby, the main contenders are Redcarpet and kramdown. There are others, but I have not used them.

Redcarpet is mature and solid. It is also highly performant and extensible. You can define your own custom tags and syntax. It allows you to pre-process and post-process content.

It has disadvantages, though. Since it adheres to the markdown standard it can be limiting. I wrote my own figure tag syntax, and found that it was being inserted between paragraph tags, leading to invalid HTML. This is not its own fault. It's how markdown works.

!![figure caption](image_url "img alt text")

An alternative is kramdown, which is written with flexibility in mind. It allows full customisation of your syntax.

Upvotes: 1

Related Questions