I’m working on a CMS in Rails.
The company that I work for currently uses a CMS written in PHP, and I
want to mimick it in Rails, and improve along the way.
The PHP variant works with templates like this:
In the root of the webdir, there are the template files, named
cms_news.html for example.
This page contains custom tags, in the form of definitions and
The definition tags go like:
They are placed on top of the file, before the tag.
PHP uses str_replace() to filter out these tags.
This definition pulls its data from SQL table ‘t_articles’
The placeholder tags define where the previously defined ‘block’
should be displayed in the page:
This prints a list of articles according to the definition.
The -tag (in cmsdef) adds a little editbutton, which can
bring up a popup within which one can modify the contents of the
With this functionality, it’s possible to build quite a website, and
manage it in a WYSIWYG-way.
But how to approach this in Rails?
The goals are simple, really… I want to be able to have designers
create regular HTML files, with a couple of special tags where they
want to display dynamic content.
Within the CMS interface, the site must be viewable in ‘preview’ and
In preview-mode, the website is rendered like the world would see it.
In edit-mode, some edit buttons appear above the dynamic spots.
Should I try to mimick it as close as possible, using Ruby’s File
library and lots of gsub’s?
Or maybe there’s a better way, using RHTML or Liquid, to achieve the
It’s a bit of an open question, and I’m just looking for thoughts or