Sha256: ad2850d5556f5ec7e5085ec0525f9a57ff5c972cfeb8ea157771ef325153ffa1
Contents?: true
Size: 1.33 KB
Versions: 26
Compression:
Stored size: 1.33 KB
Contents
require_dependency "polyblock/application_controller" module Polyblock class PolyblocksController < ApplicationController def update if params.has_key? :pbs and params[:pbs].any? params[:pbs].each do |i, attrs| pb_find = Block.where(:id => attrs[:id]) attrs.delete(:id) if pb_find.any? && pb_find.first.name == attrs[:name] pb_find.first.update_attributes!(attrs) else Block.create! attrs end end end render :text => "OK!" end 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 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 end end
Version data entries
26 entries across 26 versions & 1 rubygems