mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Merge pull request #76 from trans/master
Add split example to example servlet
This commit is contained in:
@@ -46,3 +46,8 @@ namespace :profile do
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Run example"
|
||||||
|
task :example do
|
||||||
|
ruby "-w -d -Ilib example/server/server.rb"
|
||||||
|
end
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ class Servlet < LiquidServlet
|
|||||||
{ 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true}
|
{ 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
"List of Products ~ This is a list of products with price and description."
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def products_list
|
def products_list
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
require 'webrick'
|
require 'webrick'
|
||||||
require 'rexml/document'
|
require 'rexml/document'
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../../lib/liquid'
|
DIR = File.expand_path(File.dirname(__FILE__))
|
||||||
require File.dirname(__FILE__) + '/liquid_servlet'
|
|
||||||
require File.dirname(__FILE__) + '/example_servlet'
|
require DIR + '/../../lib/liquid'
|
||||||
|
require DIR + '/liquid_servlet'
|
||||||
|
require DIR + '/example_servlet'
|
||||||
|
|
||||||
# Setup webrick
|
# Setup webrick
|
||||||
server = WEBrick::HTTPServer.new( :Port => ARGV[1] || 3000 )
|
server = WEBrick::HTTPServer.new( :Port => ARGV[1] || 3000 )
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>There are currently {{products | count}} products in the {{section}} catalog</h1>
|
<h1>{{ description | split '~' | first }}</h1>
|
||||||
|
|
||||||
|
<h2>{{ description | split '~' | last }}</h2>
|
||||||
|
|
||||||
|
<h2>There are currently {{products | count}} products in the {{section}} catalog</h2>
|
||||||
|
|
||||||
{% if cool_products %}
|
{% if cool_products %}
|
||||||
Cool products :)
|
Cool products :)
|
||||||
|
|||||||
Reference in New Issue
Block a user