I've inherited an app that has this haml to pull in an index.html.haml file for the "home" 开发者_开发技巧controller.
= fl
- if logged_in?
= render :partial => 'logged_in_home'
- else
= render :partial => 'marketing_home'
The if statement is clear, but what is the = fl doing? I can't find that anywhere in haml documentation or by googling it.
= fl
is not a built-in haml method. You could try to see if it defined in any of the following places:
- app/controllers/application_controller
- app/helpers/application_helper
- app/helpers/home_helper
- any other app/helpers/*_helper file
- library codes (lib/*)
- plugin / gem codes
My guess is that it's a local variable, especially if you are inside a partial. What happens when you run the page? What appears above the partials?
I have no idea what fl
is in your application as it probably defined by your application or one of the plugins.
But I will tell you the magic trick to figure it out. Its actually very simple:
- Stick a debugger just before it ;)
Just do
= require 'ruby-debug';debugger;fl
And refresh your page. The server should stop at this line. Use s
to step inside 'fl' function and you will find out exactly where is it in 99.99% of the cases (*)
- well, there might be cases when it will not help much, when for example a method is defined dynamically w/o properly setting source files and line.
精彩评论