My main content
Text designers would put here to test their layout
RuHL (Ruby Hypertext Language) **gem available on gemcutter: http://gemcutter.org/gems/ruhl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: What? :: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RuHL parses HTML (using Nokogiri) and by using a data-ruhl attribute, makes the contents dynamic! Let's say you have the following HTML in a file called ('hello_world.ruhl')
And you have the following method available to self: def say_hello "Hello World" end If you call RuHL::Engine.new(File.read('hello_world.ruhl')).render(self) It will return:Hello World
Notice that it removes the data-ruhl attribute. You can pass an options hash to RuHL: RuHL::Engine.new(File.read('hello_world.ruhl'), options).render(self) Right now, RuHL knows the following options: :layout => This is the file name of the layout :layout_source => If the framework (like Rails) has already read the file, pass the contents through so RuHL doesn't have to reread the file. If you don't pass :layout_source, RuHL must be able to find/read :layout :local_object => If you are rendering a show page for @person, pass the @person object into RuHL. RuHL will first try to call the methods against the local_object then try the scope. For example:John Doe | john@doe.com |
Rupert Boy | rupert@stonean.com |
Kaylee Girl | kaylee@stonean.com |
Monty Man | monty@stonean.com |
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:Text designers would put here to test their layout
First Name | Last Name | |
Andrew | Stone | andy@stonean.com |
First Name | Last Name | |
Andrew | Stone | andy@stonean.com |
First Name | Last Name | |
Andrew | Stone | andy@stonean.com |
No Users were found.
if users? == false then the "No Users were found" message appears. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: Scope object to tag block (_use):: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~First Name | Last Name | |
Andrew | Stone | andy@stonean.com |