Class: Polyblock::PolyblocksController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Polyblock::PolyblocksController
- Defined in:
- app/controllers/polyblock/polyblocks_controller.rb
Instance Method Summary collapse
Instance Method Details
#convert_haml_to_html ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/polyblock/polyblocks_controller.rb', line 20 def convert_haml_to_html haml = params[:haml] # Remove the pesky helpers haml = haml.split("= succeed \"") lines = [haml.shift] haml.each do |chunk| arg = chunk.split("\"",2)[0] block = chunk.split("\n")[1..-1].map{|line| line[2..-1]}.join("\n") lines << "#{block}\narg" end haml = lines.join("") # Run it through the engine render :text => Haml::Engine.new(haml).render end |
#convert_html_to_haml ⇒ Object
37 38 39 40 41 42 |
# File 'app/controllers/polyblock/polyblocks_controller.rb', line 37 def convert_html_to_haml # html = if params.has_key? :cbid then ContentBlock.find(params[:cbid]).content else params[:html] end # engine = Html2haml::HTML.new html, :erb => false, :xhtml => false engine = Html2haml::HTML.new params[:html], :erb => false, :xhtml => false render :text => engine.render end |
#update ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/polyblock/polyblocks_controller.rb', line 6 def update if params.has_key? :pbs and params[:pbs].any? params[:pbs].each do |i, attrs| pb_attrs = {} pb_attrs[:id] = attrs[:id] if attrs.has_key?(:id) and !attrs[:id].blank? pb_attrs[:name] = attrs[:name] if attrs.has_key?(:name) and !attrs[:name].blank? pb = Block.find_or_initialize_by pb_attrs pb.content = attrs[:content] pb.save! end end render :text => "OK!" end |