Ruhl (Ruby Hypertext Language) This project is here to flesh out an idea. What I want is to have developers work with HTML and with the simple addition of a 'data-ruhl' attribute, convert it to a dynamic page. At no time in the dev process would the view be unviewable in a browser. The view could actually retain the original template data the designer used because this replaces the content. I think this is a nice plus. Notes (use cases) for me to remember: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Basic Use :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Method :page_header would know how to represent itself in the context of the h1 element. The Ruby executed would replace the content of the element it was being called on. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Replacing attribute values :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ content: meta_description is telling the parser to replace attribute 'content' with results from meta_description method. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Don't use iterators in views :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
John Doe john@doe.com
The above will call the :user_list method and iterate over the results. For each result it will duplicate the tag and it's contents. For the above example this means: John Doe john@doe.com is duplicated for each user in user_list. If user_list return an array of User objects like: [ User.create(:name => 'Rupert Boy', :email => 'rupert@stonean.com'), User.create(:name => 'Kaylee Girl', :email => 'kaylee@stonean.com'), User.create(:name => 'Monty Man', :email => 'monty@stonean.com')]
Rupert Boy rupert@stonean.com
Kaylee Girl kaylee@stonean.com
Monty Man monty@stonean.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Using a Layout :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Layout: This is a title template
Fragment:

I am a templated headline

Lorem ipsum dolor sit amet

To use: Ruhl::Engine.new(File.read(fragment), :layout => path_to_layout).render(self) Returns the expected result of parsed Layout w/ parsed Fragment. Note the use of the _render_ method. This is a 'special' method that Ruhl uses to inject the results of the parsed fragment into the layout. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Using a Partial :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Main: This is a title template

My main content

Text designers would put here to test their layout

Sidebar:

Real Sidebarlinks

To use: Ruhl::Engine.new(File.read(path_to_main)).render(self) Returns the expected result of parsed Main with sidebar div contents replaced with parsed sidebar partial contents. Note the use of the _partial key. This is a 'special' key that Ruhl uses to inject the results of the parsed partial into the contents of the calling node. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Conditional display of block (_render_if):: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a title template

This is the header template

First Name Last Name Email
Andrew Stone andy@stonean.com
if has_users? returns false then the div (including it's contents) are not shown on output. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Conditional display of tag (_if):: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a title template

This is the header template

First Name Last Name Email
Andrew Stone andy@stonean.com
if email == nil then the td is not shown. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Notes :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * No eval (I don't think eval is evil, it's just not the way this works) * The data-ruhl attribute is always removed from the output. * Each method called must accept a tag parameter. e.g def page_header(tag) * Since it's just HTML, syntax highlighting is built-in. For vim, just add this to your ~/.vimrc: au BufNewFile,BufRead *.ruhl set filetype=html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: TODO :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1) Test more scenarios