[Nitro] Nitro and Amrita

TRANS transfire at gmail.com
Mon Apr 17 08:00:14 EDT 2006


On 4/16/06, George Moschovitis <george.moschovitis at gmail.com> wrote:
> > I wouldn't neccessarily say that b/c Amrita is different from Nitro's
> > templates. Nitro's templates are more like PHPs, while Amrita
> > completely separates layout from data.
>
> NOT really. Nitro Templates can be used in PHP like mode and/or Amrita
> style mode. Have a look at this.
>
>
> def action
>   @user = User.current_user
>   @name = @user.name
>   @articles = @user.articles
>   @something =...
> end
>
> action.xhtml
>
> <div if="@user.admin">
>   <p>#@name</p>
>   <ul for="a in @articles">
>      <li>#{a.title}</li>
>   </ul>
> </div>
>
> This is fully separated layout from data.

Not quite. Code elements are still being directly referenced from
within the markup, ie. @name and @articles. In Amrita you don't even
have that.

  <div id="user_admin">
    <p id="name">name here</p>
    <ul id="articles">
       <li id="title">title here</li>
    </ul>
  </div>

Then in code:

  if @user.admin
    data = {
      :user_admin => {
        :name => @name
        :articles => @articles.collect { |a|
          { :title => a.title }
        }
      }
    }
  else
    data = { :user_admin => nil }
  end

Amrita uses the data structure to determine the layout structure.

T.




More information about the Nitro-general mailing list