1.

How Do I Render Templates Nested In Subdirectories?

Answer»

Sinatra apps do not typically have a very complex file hierarchy under VIEWS. First, CONSIDER whether you really need subdirectories at all. If so,

you can use the views/foo/bar.haml file as a TEMPLATE with:

get '/' do

haml :'foo/bar'

END

This is basically the same as sending #to_sym to the filename and can also be written as:

get '/' do

haml 'foo/bar'.to_sym

end

Sinatra apps do not typically have a very complex file hierarchy under views. First, consider whether you really need subdirectories at all. If so,

you can use the views/foo/bar.haml file as a template with:

get '/' do

haml :'foo/bar'

end

This is basically the same as sending #to_sym to the filename and can also be written as:

get '/' do

haml 'foo/bar'.to_sym

end



Discussion

No Comment Found