Class/Module Index [+]

Quicksearch

Ezamar

Ezamar is a very simple (and at no means complete) reimplementation of the Templating-engine found in Nitro.

Since Nitros templating is based on REXML and Ezamar is not there are vast differences, but it tries to keep the look and feel as close as possible.


Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com

All files in this distribution are subject to the terms of the Ruby license.


This applies a morphing-replace for the template.

To use the functionality of Morpher you will need to have hpricot installed, you will get one error in case you don't and the method will be replaced by a stub that simply returns the template.

The method first checks if you use any morphers and just skips the step if you don't, this should give quite some speedup for smaller templates that don't use this functionality at all. the check works by searching the morphs with appended '=' in the template. There may be a few cases where this won't work since we cannot make any assumptions on the format.

If you want to turn this functionality off, either remove Morpher from:

Ramaze::Template::Ezamar::TRANSFORM_PIPELINE

or do:

Ramaze::Morpher::MORPHS.clear

The latter is a tad slower, but i mention the possibility in case you find good use for it.

You can add your own morphers in Ramaze::Morpher::MORPHS

For Example:

Morpher::MORPHS['if'] = '<?r %morph %expression ?>%content<?r end ?>'

Now, assuming that some tag in your template is '<a if="@foo">x</a>'

%morph stands for the name of your morph: 'if' %expression is the stuff you write in the attribute: '@foo' %content is the tag without the attribute (and all inside): '<a>x</a>'


Example:

Your Element called Page:

class Page < Ezamar::Element
  def render
    %{
     <html>
       <h1>
         #@title
       </h1>
       #{content}
     </html>
     }
  end
end

and one called SideBar

class SideBar < Ezamar::Element
  def render
    %{
      <a href="http://something.com">something</a>
     }
   end
 end

and your template (any template for any action):

<Page title="Test">
  <SideBar />
  <p>
    Hello, World!
  </p>
</Page>

would result in:

<html>
  <h1>
    Test
  </h1>
  <p>
    Hello, World!
  </p>
</html>

Constants

VERSION

[Validate]

Generated with the Darkfish Rdoc Generator 2.