mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Add split example to example servlet.
This commit is contained in:
5
Rakefile
5
Rakefile
@@ -48,3 +48,8 @@ namespace :profile do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "Run example"
|
||||
task :example do
|
||||
ruby "-w -d -Ilib example/server/server.rb"
|
||||
end
|
||||
|
||||
@@ -25,7 +25,11 @@ class Servlet < LiquidServlet
|
||||
def products
|
||||
{ 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true}
|
||||
end
|
||||
|
||||
|
||||
def description
|
||||
"List of Products ~ This is a list of products with price and description."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def products_list
|
||||
@@ -34,4 +38,4 @@ class Servlet < LiquidServlet
|
||||
{'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
require 'webrick'
|
||||
require 'rexml/document'
|
||||
|
||||
require File.dirname(__FILE__) + '/../../lib/liquid'
|
||||
require File.dirname(__FILE__) + '/liquid_servlet'
|
||||
require File.dirname(__FILE__) + '/example_servlet'
|
||||
DIR = File.expand_path(File.dirname(__FILE__))
|
||||
|
||||
require DIR + '/../../lib/liquid'
|
||||
require DIR + '/liquid_servlet'
|
||||
require DIR + '/example_servlet'
|
||||
|
||||
# Setup webrick
|
||||
server = WEBrick::HTTPServer.new( :Port => ARGV[1] || 3000 )
|
||||
server.mount('/', Servlet)
|
||||
trap("INT"){ server.shutdown }
|
||||
server.start
|
||||
server.start
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
</head>
|
||||
|
||||
<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 %}
|
||||
Cool products :)
|
||||
|
||||
Reference in New Issue
Block a user