stonean

trying to be better than I was yesterday

RuHL Options

RuHL accepts an option hash to the engine. The are passed as:

  RuHL::Engine.new(File.read(‘hello_world.ruhl’), options).render(self)

: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 and read :layout


:local_object (aliased as :object)

If you are rendering a show page for @person, pass the @person object into RuHL.

  RuHL::Engine.new(File.read(‘hello_world.ruhl’), 
    {:object => @person}).render(self)

RuHL will first try to call the methods against the local_object then try the scope.

For example:

  <li data-ruhl="first_name">

RuHL will first try @person.first_name.

Rails

To do this in Rails you need to have your controller action looks something like:

  def show
    account = Account.find(params[:id])

    render :template => 'accounts/show', :locals => {:object => account}
  end

I haven’t found an easier way, yet… This works and I’ll revisit how to simplify this at a later date.

Copyright © 2010 stonean. All rights reserved.
Powered by Thoth.