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