Sorry guys, all my bad. After I read my post again, I've found that I was really using Ruby interpolation rather than HAML interpolation, just like Nathan said. I've forgotten the haml code is a string. LOL
Thanks for your help~ On 9月16日, 下午2时48分, Gimi <[email protected]> wrote: > Thanks for all the replies, guys. > > My code is really simple, just a file like this: > > require 'rubygems' > require 'sinatra/base' > require 'haml' > > class MyApp < Sinatra::Base > set :haml, :format => :html5, :ugly => true, :excape_html => true > > get '/' do > @msg = "A message" > haml :index > end > > template :layout do > <<_LAYOUT_ > !!! > %html > %head > %body > %p Here is the msg: #...@msg} > #main!= yield > _LAYOUT_ > end > > template :index do > <<_INDEX_ > %div Some other stuff goes here ... > _INDEX_ > end > > end > > Simple, right? > In the layout, @msg is nil. So,what's wrong here? > > On 9月16日, 上午2时20分, Nathan Weizenbaum <[email protected]> wrote: > > > How are you embedding the Haml code? Could it be that the #{} is being read > > as normal Ruby interpolation rather than Haml interpolation? > > > On Tue, Sep 15, 2009 at 1:07 AM, Gimi <[email protected]> wrote: > > > > I was using Sinatra 0.9.4 + haml 2.2.4. > > > > I defined a variable in a get method, like: > > > get '/' do > > > @msg = "New message" > > > end > > > > And I wanted to retrieve it on my haml template through Interpolation, > > > like: > > > %p You've got #...@msg} > > > > But it turned out that @msg is nil! Why? Am I missing anything? > > > > Any body can give me a tip? Any help is greatly appreciated! > > > > P.S. It didn't work event with haml-edge 2.3.27. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
