Class: Swee::View
Class Method Summary collapse
-
.render_404 ⇒ Object
404页面.
Instance Method Summary collapse
-
#create_view ⇒ Object
读取视图文件 controller/action.erb.
-
#get_binding ⇒ Object
把controller 实变量绑定到 view 层.
-
#initialize(controller) ⇒ View
constructor
A new instance of View.
Methods included from Helper
#form_for, #image_tag, #parse_tag_options, #raw, #tag
Constructor Details
Class Method Details
Instance Method Details
#create_view ⇒ Object
读取视图文件 controller/action.erb
22 23 24 25 |
# File 'lib/swee/view.rb', line 22 def create_view erb = ::ERB.new(File.read(File.("views/#{@controller._name}/#{@controller.action_name}.erb", ENV["app_path"]))) erb.result(binding) end |
#get_binding ⇒ Object
把controller 实变量绑定到 view 层
14 15 16 17 18 |
# File 'lib/swee/view.rb', line 14 def get_binding @controller.instance_variables.each do |v| instance_variable_set v, @controller.instance_variable_get(v) end end |