Sha256: 356bcf2e1ea78cd74084cfb1b315e5fa47900dedf4085cb436928e804abad4b8

Contents?: true

Size: 701 Bytes

Versions: 34

Compression:

Stored size: 701 Bytes

Contents

class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet

  def do_GET(req, res)
    handle(:get, req, res)
  end

  def do_POST(req, res)
    handle(:post, req, res)
  end
  
  private
  
  def handle(type, req, res)
    @request, @response = req, res
    
    @request.path_info =~ /(\w+)$/
    @action = $1 || 'index'    
    @assigns = send(@action) if respond_to?(@action)    

    @response['Content-Type'] = "text/html"
    @response.status = 200
    @response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])      
  end
  
  def read_template(filename = @action)
    File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquid" )
  end
end

Version data entries

34 entries across 34 versions & 4 rubygems

Version Path
liquor-0.1.1 example/server/liquid_servlet.rb
liquor-0.1.0 example/server/liquid_servlet.rb
liquid_cms-0.3.2.0 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.2.0 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.1.1 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.1.0 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.1.0 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.13 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.0.10 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.0.9 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.12 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.11 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.10 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.0.8 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.9 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.0.7 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.0.6 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.8 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.3.0.5 lib/generators/liquid_cms/templates/vendor/plugins/liquid/example/server/liquid_servlet.rb
liquid_cms-0.2.0.7 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/example/server/liquid_servlet.rb