On 17/02/11 12:06, cz wrote: > Hi: > > How do I embed Ruby code in Haml? I am passing an array via a get > request. The array can be displayed using > %p #{@ary} > > However, if I try.. > > for x in 0...#{@ary.length} > print #{@ary.at(x)} > end > > I get an error, undefined variable x. What is going on? > > cz You need '-' at the start of a line with ruby code otherwise haml just passes it through Also indentation is important. - for x in 0.. / ary.length #{@ary.at(x)} e.g. % (echo '- for x in 0..5' ; echo ' #{x}') | haml 1 2 3 4 5 you don't need the 'end' that you do in normal ruby as the indentation defines the block (much like in python).