0

I try to convert a ramaze app to padrino(0.12.1) Current problem that I have is instance variable in padrino/sinatra controller can't be read by liquid template.

controllers/main.rb

Myproject::App.controllers :main do
  get :index, :map => '/' do
    @name = 'foo'
    render 'main/index'
  end

views/layouts/application.liquid

...html code here...
 Testing
 {{ content }}
...html code here...

views/layouts/main.liquid

Hello {{ name }}

Result should be

"Testing Hello foo", but I only get "Testing Hello".

Any clue? Tnx.

mhd
  • 4,561
  • 10
  • 37
  • 53

1 Answers1

2

Liquid doesn’t allow evaluating Ruby code as part of the templates, which includes accessing instance variables. You can set locals through a hash:

render 'main/index', :locals => { :name => 'foo' }

foo will then be available in the template.

matt
  • 78,533
  • 8
  • 163
  • 197
  • Ok, now that works,thanks! but I have no idea why I don't need this kind of thing in ramaze..oh well.. – mhd Apr 20 '14 at 06:05