Merge branch 'master' of git@github.com:tobi/liquid

Conflicts:
	lib/liquid.rb
	lib/liquid/context.rb
	lib/liquid/variable.rb
	test/standard_tag_test.rb
This commit is contained in:
Tobias Lütke
2009-06-15 09:00:30 -04:00
66 changed files with 3812 additions and 404 deletions

View File

@@ -1,9 +1,13 @@
* Ruby 1.9.1 bugfixes
* Fix LiquidView for Rails 2.2. Fix local assigns for all versions of Rails
* Fixed gem install rake task
* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins
* Added If with or / and expressions
* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods.
* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods.
* Added more tags to standard library
@@ -22,17 +26,17 @@
* Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond]
* Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond]
{{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }}
* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke]
{{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }}
* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke]
class ProductDrop < Liquid::Drop
def top_sales
Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
end
end
end
t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' )
t.render('product' => ProductDrop.new )

View File

@@ -21,4 +21,11 @@ Hoe.new(PKG_NAME, PKG_VERSION) do |p|
p.author = "Tobias Luetke"
p.email = "tobi@leetsoft.com"
p.url = "http://www.liquidmarkup.org"
end
desc "Run the liquid profile/perforamce coverage"
task :profile do
ruby "performance/shopify.rb"
end

View File

@@ -5,32 +5,43 @@
#
# ActionView::Base::register_template_handler :liquid, LiquidView
class LiquidView
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
_response url _request _cookies variables_added _flash params _headers request cookies
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
@helpers @assigns_added @template @_render_stack @template_format @assigns )
def self.call(template)
"LiquidView.new(self).render(template, local_assigns)"
end
def initialize(action_view)
@action_view = action_view
def initialize(view)
@view = view
end
def render(template, local_assigns_for_rails_less_than_2_1_0 = nil)
@action_view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
assigns = @action_view.assigns.dup
def render(template, local_assigns = nil)
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
# template is a Template object in Rails >=2.1.0, a source string previously.
if template.respond_to? :source
source = template.source
local_assigns = template.locals
# Rails 2.2 Template has source, but not locals
if template.respond_to?(:source) && !template.respond_to?(:locals)
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
hash[ivar[1..-1]] = @view.instance_variable_get(ivar)
hash
end
else
source = template
local_assigns = local_assigns_for_rails_less_than_2_1_0
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
end
if content_for_layout = @action_view.instance_variable_get("@content_for_layout")
source = template.respond_to?(:source) ? template.source : template
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
if content_for_layout = @view.instance_variable_get("@content_for_layout")
assigns['content_for_layout'] = content_for_layout
end
assigns.merge!(local_assigns)
assigns.merge!(local_assigns.stringify_keys)
liquid = Liquid::Template.parse(source)
liquid.render(assigns, :filters => [@action_view.controller.master_helper_module], :registers => {:action_view => @action_view, :controller => @action_view.controller})
liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
end
def compilable?

View File

@@ -22,41 +22,29 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
module Liquid
# Basic apperence:
# Tags {% look like this %}
TagStart = /\{%/
TagEnd = /%\}/
# Variables {{look}} like {{this}}
FilterSeparator = /\|/
ArgumentSeparator = ','
FilterArgumentSeparator = ':'
VariableAttributeSeparator = '.'
TagStart = /\{\%/
TagEnd = /\%\}/
VariableSignature = /\(?[\w\-\.\[\]]\)?/
VariableSegment = /[\w\-]/
VariableStart = /\{\{/
VariableEnd = /\}\}/
# Arguments are passed {% like: this %}
FilterArgumentSeparator = ':'
# Hashes are separated {{ like.this }}
VariableAttributeSeparator = '.'
# Filters are piped in {{ like | this }}
FilterSeparator = /\|/
# Muliple arguments are {% separated: like, this %}
ArgumentSeparator = ','
# Lexical parsing regexped go below.
VariableSignature = /\(?[\w\-\.\[\]]\)?/
VariableSegment = /[\w\-]\??/
VariableIncompleteEnd = /\}\}?/
QuotedString = /"[^"]+"|'[^']+'/
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
StrictQuotedFragment = /"[^"]+"|'[^']+'|[^\s,\|,\:,\,]+/
FirstFilterArgument = /#{FilterArgumentSeparator}(?:#{StrictQuotedFragment})/
OtherFilterArgument = /#{ArgumentSeparator}(?:#{StrictQuotedFragment})/
SpacelessFilter = /#{FilterSeparator}(?:#{StrictQuotedFragment})(?:#{FirstFilterArgument}(?:#{OtherFilterArgument})*)?/
Expression = /(?:#{QuotedFragment}(?:#{SpacelessFilter})*)/
TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/
AnyStartingTag = /\{\{|\{\%/
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/
VariableParser = /\[[^\]]+\]|#{VariableSegment}+/
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/
end
require 'liquid/drop'

View File

@@ -1,19 +1,19 @@
module Liquid
class Block < Tag
def parse(tokens)
@nodelist ||= []
@nodelist.clear
while token = tokens.shift
while token = tokens.shift
case token
when /^#{TagStart}/
when /^#{TagStart}/
if token =~ /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/
# if we found the proper block delimitor just end parsing here and let the outer block
# proceed
# proceed
if block_delimiter == $1
end_tag
return
@@ -23,10 +23,10 @@ module Liquid
if tag = Template.tags[$1]
@nodelist << tag.new($1, $2, tokens)
else
# this tag is not registered with the system
# this tag is not registered with the system
# pass it to the current block for special handling or error reporting
unknown_tag($1, $2, tokens)
end
end
else
raise SyntaxError, "Tag '#{token}' was not properly terminated with regexp: #{TagEnd.inspect} "
end
@@ -37,19 +37,19 @@ module Liquid
else
@nodelist << token
end
end
# Make sure that its ok to end parsing in the current block.
# Effectively this method will throw and exception unless the current block is
# of type Document
end
# Make sure that its ok to end parsing in the current block.
# Effectively this method will throw and exception unless the current block is
# of type Document
assert_missing_delimitation!
end
def end_tag
end
def end_tag
end
def unknown_tag(tag, params, tokens)
case tag
case tag
when 'else'
raise SyntaxError, "#{block_name} tag does not expect else tag"
when 'end'
@@ -61,7 +61,7 @@ module Liquid
def block_delimiter
"end#{block_name}"
end
end
def block_name
@tag_name
@@ -77,7 +77,7 @@ module Liquid
def render(context)
render_all(@nodelist, context)
end
protected
def assert_missing_delimitation!
@@ -86,12 +86,12 @@ module Liquid
def render_all(list, context)
list.collect do |token|
begin
begin
token.respond_to?(:render) ? token.render(context) : token
rescue Exception => e
rescue Exception => e
context.handle_error(e)
end
end
end
end
end
end
end
end
end

View File

@@ -3,7 +3,7 @@ module Liquid
#
# Example:
#
# c = Condition.new('1', '==', '1')
# c = Condition.new('1', '==', '1')
# c.evaluate #=> true
#
class Condition #:nodoc:
@@ -17,33 +17,33 @@ module Liquid
'<=' => :<=,
'contains' => lambda { |cond, left, right| left.include?(right) },
}
def self.operators
@@operators
end
attr_reader :attachment
attr_accessor :left, :operator, :right
def initialize(left = nil, operator = nil, right = nil)
@left, @operator, @right = left, operator, right
@child_relation = nil
@child_condition = nil
end
def evaluate(context = Context.new)
result = interpret_condition(left, right, operator, context)
result = interpret_condition(left, right, operator, context)
case @child_relation
when :or
when :or
result || @child_condition.evaluate(context)
when :and
when :and
result && @child_condition.evaluate(context)
else
result
end
end
end
end
def or(condition)
@child_relation, @child_condition = :or, condition
end
@@ -51,25 +51,25 @@ module Liquid
def and(condition)
@child_relation, @child_condition = :and, condition
end
def attach(attachment)
@attachment = attachment
end
def else?
false
end
end
def inspect
"#<Condition #{[@left, @operator, @right].compact.join(' ')}>"
end
private
def equal_variables(left, right)
if left.is_a?(Symbol)
if right.respond_to?(left)
return right.send(left.to_s)
return right.send(left.to_s)
else
return nil
end
@@ -77,47 +77,44 @@ module Liquid
if right.is_a?(Symbol)
if left.respond_to?(right)
return left.send(right.to_s)
return left.send(right.to_s)
else
return nil
end
end
left == right
end
left == right
end
def interpret_condition(left, right, op, context)
# If the operator is empty this means that the decision statement is just
# a single variable. We can just poll this variable from the context and
# If the operator is empty this means that the decision statement is just
# a single variable. We can just poll this variable from the context and
# return this as the result.
return context[left] if op == nil
return context[left] if op == nil
left, right = context[left], context[right]
operation = self.class.operators[op] || raise(ArgumentError.new("Unknown operator #{op}"))
if operation.respond_to?(:call)
operation.call(self, left, right)
elsif left.respond_to?(operation) and right.respond_to?(operation)
elsif left.respond_to?(operation) and right.respond_to?(operation)
left.send(operation, right)
else
nil
end
end
end
end
end
class ElseCondition < Condition
def else?
def else?
true
end
def evaluate(context)
true
end
end
end
end

View File

@@ -56,7 +56,7 @@ module Liquid
if strainer.respond_to?(method)
strainer.__send__(method, *args)
else
args.first
raise FilterNotFound, "Filter '#{method}' not found"
end
end
@@ -156,16 +156,12 @@ module Liquid
# fetches an object starting at the local scope and then moving up
# the hierachy
def find_variable(key)
@scopes.each do |scope|
if scope.has_key?(key)
variable = scope[key]
variable = scope[key] = variable.call(self) if variable.is_a?(Proc)
variable = variable.to_liquid
variable.context = self if variable.respond_to?(:context=)
return variable
end
end
nil
scope = @scopes[0..-2].find { |s| s.has_key?(key) } || @scopes.last
variable = scope[key]
variable = scope[key] = variable.call(self) if variable.is_a?(Proc)
variable = variable.to_liquid
variable.context = self if variable.respond_to?(:context=)
return variable
end
# resolves namespaced queries gracefully.

View File

@@ -1,17 +1,17 @@
module Liquid
class Document < Block
class Document < Block
# we don't need markup to open this block
def initialize(tokens)
parse(tokens)
end
# There isn't a real delimter
end
# There isn't a real delimter
def block_delimiter
[]
end
# Document blocks don't need to be terminated since they are not actually opened
def assert_missing_delimitation!
end
end
end
end
end

View File

@@ -1,9 +1,9 @@
module Liquid
# A drop in liquid is a class which allows you to to export DOM like things to liquid
# Methods of drops are callable.
# The main use for liquid drops is the implement lazy loaded objects.
# If you would like to make data available to the web designers which you don't want loaded unless needed then
# Methods of drops are callable.
# The main use for liquid drops is the implement lazy loaded objects.
# If you would like to make data available to the web designers which you don't want loaded unless needed then
# a drop is a great way to do that
#
# Example:
@@ -13,38 +13,39 @@ module Liquid
# Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
# end
# end
#
# tmpl = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {%endfor%} ' )
# tmpl.render('product' => ProductDrop.new ) # will invoke top_sales query.
#
# Your drop can either implement the methods sans any parameters or implement the before_method(name) method which is a
# tmpl = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {%endfor%} ' )
# tmpl.render('product' => ProductDrop.new ) # will invoke top_sales query.
#
# Your drop can either implement the methods sans any parameters or implement the before_method(name) method which is a
# catch all
class Drop
attr_writer :context
# Catch all for the method
# Catch all for the method
def before_method(method)
nil
end
# called by liquid to invoke a drop
def invoke_drop(method)
if self.class.public_instance_methods.include?(method.to_s)
send(method.to_sym)
else
def invoke_drop(method)
# for backward compatibility with Ruby 1.8
methods = self.class.public_instance_methods.map { |m| m.to_s }
if methods.include?(method.to_s)
send(method.to_sym)
else
before_method(method)
end
end
def has_key?(name)
true
end
def to_liquid
self
end
alias :[] :invoke_drop
end
end

View File

@@ -1,7 +1,7 @@
module Liquid
class TableRow < Block
Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/
class TableRow < Block
Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/
def initialize(tag_name, markup, tokens)
if markup =~ Syntax
@variable_name = $1
@@ -13,62 +13,62 @@ module Liquid
else
raise SyntaxError.new("Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3")
end
super
super
end
def render(context)
def render(context)
collection = context[@collection_name] or return ''
if @attributes['limit'] or @attributes['offset']
limit = context[@attributes['limit']] || -1
offset = context[@attributes['offset']] || 0
collection = collection[offset.to_i..(limit.to_i + offset.to_i - 1)]
end
length = collection.length
cols = context[@attributes['cols']].to_i
row = 1
col = 0
result = ["<tr class=\"row1\">\n"]
context.stack do
context.stack do
collection.each_with_index do |item, index|
context[@variable_name] = item
context['tablerowloop'] = {
'length' => length,
'index' => index + 1,
'index0' => index,
'col' => col + 1,
'col0' => col,
'index0' => index,
'index' => index + 1,
'index0' => index,
'col' => col + 1,
'col0' => col,
'index0' => index,
'rindex' => length - index,
'rindex0' => length - index -1,
'first' => (index == 0),
'last' => (index == length - 1),
'col_first' => (col == 0),
'col_last' => (col == cols - 1)
}
}
col += 1
result << ["<td class=\"col#{col}\">"] + render_all(@nodelist, context) + ['</td>']
if col == cols and not (index == length - 1)
if col == cols and not (index == length - 1)
col = 0
row += 1
result << ["</tr>\n<tr class=\"row#{row}\">"]
result << ["</tr>\n<tr class=\"row#{row}\">"]
end
end
end
result + ["</tr>\n"]
end
end
end
Template.register_tag('tablerow', TableRow)
end
Template.register_tag('tablerow', TableRow)
end

View File

@@ -18,7 +18,7 @@
# end
# end
#
# if you want to extend the drop to other methods you can defines more methods
# if you want to extend the drop to other methods you can defines more methods
# in the class <YourClass>::LiquidDropClass
#
# class SomeClass::LiquidDropClass
@@ -37,11 +37,11 @@
# output:
# 'this comes from an allowed method and this from another allowed method'
#
# You can also chain associations, by adding the liquid_method call in the
# You can also chain associations, by adding the liquid_method call in the
# association models.
#
class Module
def liquid_methods(*allowed_methods)
drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end"
define_method :to_liquid do
@@ -58,5 +58,5 @@ class Module
end
end
end
end

View File

@@ -1,52 +1,51 @@
require 'set'
module Liquid
parent_object = if defined? BlankObject
BlankObject
else
Object
end
# Strainer is the parent class for the filters system.
# New filters are mixed into the strainer class which is then instanciated for each liquid template render run.
# Strainer is the parent class for the filters system.
# New filters are mixed into the strainer class which is then instanciated for each liquid template render run.
#
# One of the strainer's responsibilities is to keep malicious method calls out
# One of the strainer's responsibilities is to keep malicious method calls out
class Strainer < parent_object #:nodoc:
INTERNAL_METHOD = /^__/
@@required_methods = Set.new([:__send__, :__id__, :respond_to?, :extend, :methods, :class])
INTERNAL_METHOD = /^__/
@@required_methods = Set.new([:__id__, :__send__, :respond_to?, :extend, :methods, :class, :object_id])
@@filters = {}
def initialize(context)
@context = context
end
def self.global_filter(filter)
raise ArgumentError, "Passed filter is not a module" unless filter.is_a?(Module)
@@filters[filter.name] = filter
end
def self.create(context)
strainer = Strainer.new(context)
@@filters.each { |k,m| strainer.extend(m) }
strainer
end
def respond_to?(method, include_private = false)
method_name = method.to_s
return false if method_name =~ INTERNAL_METHOD
return false if @@required_methods.include?(method_name)
super
end
# remove all standard methods from the bucket so circumvent security
# problems
instance_methods.each do |m|
unless @@required_methods.include?(m.to_sym)
# remove all standard methods from the bucket so circumvent security
# problems
instance_methods.each do |m|
unless @@required_methods.include?(m.to_sym)
undef_method m
end
end
end
end
end

View File

@@ -1,26 +1,26 @@
module Liquid
class Tag
attr_accessor :nodelist
def initialize(tag_name, markup, tokens)
@tag_name = tag_name
@markup = markup
parse(tokens)
end
def parse(tokens)
end
def name
self.class.name.downcase
end
def render(context)
''
end
end
end
end

View File

@@ -1,5 +1,5 @@
module Liquid
# Capture stores the result of a block into a variable without rendering it inplace.
#
# {% capture heading %}
@@ -8,28 +8,28 @@ module Liquid
# ...
# <h1>{{ monkeys }}</h1>
#
# Capture is useful for saving content for use later in your template, such as
# Capture is useful for saving content for use later in your template, such as
# in a sidebar or footer.
#
class Capture < Block
Syntax = /(\w+)/
def initialize(tag_name, markup, tokens)
def initialize(tag_name, markup, tokens)
if markup =~ Syntax
@to = $1
else
raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]")
end
super
super
end
def render(context)
output = super
context[@to] = output.to_s
context[@to] = output.join
''
end
end
end
Template.register_tag('capture', Capture)
end
end

View File

@@ -1,120 +1,121 @@
module Liquid
# Templates are central to liquid.
# Interpretating templates is a two step process. First you compile the
# source code you got. During compile time some extensive error checking is performed.
# your code should expect to get some SyntaxErrors.
# Templates are central to liquid.
# Interpretating templates is a two step process. First you compile the
# source code you got. During compile time some extensive error checking is performed.
# your code should expect to get some SyntaxErrors.
#
# After you have a compiled template you can then <tt>render</tt> it.
# You can use a compiled template over and over again and keep it cached.
# After you have a compiled template you can then <tt>render</tt> it.
# You can use a compiled template over and over again and keep it cached.
#
# Example:
#
# Example:
#
# template = Liquid::Template.parse(source)
# template.render('user_name' => 'bob')
#
class Template
attr_accessor :root
@@file_system = BlankFileSystem.new
class <<self
class << self
def file_system
@@file_system
end
def file_system=(obj)
@@file_system = obj
end
def register_tag(name, klass)
def register_tag(name, klass)
tags[name.to_s] = klass
end
end
def tags
@tags ||= {}
end
# Pass a module with filter methods which should be available
# Pass a module with filter methods which should be available
# to all liquid views. Good for registering the standard library
def register_filter(mod)
def register_filter(mod)
Strainer.global_filter(mod)
end
end
# creates a new <tt>Template</tt> object from liquid source code
def parse(source)
template = Template.new
template.parse(source)
template
end
end
end
# creates a new <tt>Template</tt> from an array of tokens. Use <tt>Template.parse</tt> instead
def initialize
end
# Parse source code.
# Returns self for easy chaining
# Parse source code.
# Returns self for easy chaining
def parse(source)
@root = Document.new(tokenize(source))
self
end
def registers
def registers
@registers ||= {}
end
def assigns
@assigns ||= {}
end
def errors
@errors ||= []
end
# Render takes a hash with local variables.
#
# if you use the same filters over and over again consider registering them globally
# if you use the same filters over and over again consider registering them globally
# with <tt>Template.register_filter</tt>
#
#
# Following options can be passed:
#
#
# * <tt>filters</tt> : array with local filters
# * <tt>registers</tt> : hash with register variables. Those can be accessed from
# filters and tags and might be useful to integrate liquid more with its host application
# * <tt>registers</tt> : hash with register variables. Those can be accessed from
# filters and tags and might be useful to integrate liquid more with its host application
#
def render(*args)
return '' if @root.nil?
return '' if @root.nil?
context = case args.first
when Liquid::Context
args.shift
when Hash
self.assigns.merge!(args.shift)
Context.new(assigns, registers, @rethrow_errors)
a = args.shift
assigns.each { |k,v| a[k] = v unless a.has_key?(k) }
Context.new(a, registers, @rethrow_errors)
when nil
Context.new(assigns, registers, @rethrow_errors)
Context.new(assigns.dup, registers, @rethrow_errors)
else
raise ArgumentError, "Expect Hash or Liquid::Context as parameter"
end
case args.last
when Hash
options = args.pop
if options[:registers].is_a?(Hash)
self.registers.merge!(options[:registers])
self.registers.merge!(options[:registers])
end
if options[:filters]
context.add_filters(options[:filters])
end
end
when Module
context.add_filters(args.pop)
context.add_filters(args.pop)
when Array
context.add_filters(args.pop)
context.add_filters(args.pop)
end
begin
# render the nodelist.
# for performance reasons we get a array back here. join will make a string out of it
@@ -123,24 +124,24 @@ module Liquid
@errors = context.errors
end
end
def render!(*args)
@rethrow_errors = true; render(*args)
end
private
# Uses the <tt>Liquid::TemplateParser</tt> regexp to tokenize the passed source
def tokenize(source)
source = source.source if source.respond_to?(:source)
source = source.source if source.respond_to?(:source)
return [] if source.to_s.empty?
tokens = source.split(TemplateParser)
# removes the rogue empty element at the beginning of the array
tokens.shift if tokens[0] and tokens[0].empty?
tokens.shift if tokens[0] and tokens[0].empty?
tokens
end
end
end
end

View File

@@ -21,8 +21,7 @@ module Liquid
@name = match[1]
if markup.match(/#{FilterSeparator}\s*(.*)/)
filters = Regexp.last_match(1).split(/#{FilterSeparator}/)
filters.each do |f|
filters.each do |f|
if matches = f.match(/\s*(\w+)/)
filtername = matches[1]
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*(#{QuotedFragment})/).flatten
@@ -35,8 +34,7 @@ module Liquid
def render(context)
return '' if @name.nil?
output = context[@name]
@filters.inject(output) do |output, filter|
@filters.inject(context[@name]) do |output, filter|
filterargs = filter[1].to_a.collect do |a|
context[a]
end
@@ -46,7 +44,6 @@ module Liquid
raise FilterNotFound, "Error - filter '#{filter[0]}' in '#{@markup.strip}' could not be found."
end
end
output
end
end
end
end

View File

@@ -1,10 +1,10 @@
Gem::Specification.new do |s|
s.name = %q{liquid}
s.version = "1.9.0"
s.specification_version = 2 if s.respond_to? :specification_version=
s.version = "2.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Tobias Luetke"]
s.date = %q{2008-06-23}
s.date = %q{2009-04-13}
s.description = %q{A secure non evaling end user template engine with aesthetic markup.}
s.email = %q{tobi@leetsoft.com}
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
@@ -14,6 +14,16 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--main", "README.txt"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{liquid}
s.rubygems_version = %q{1.2.0}
s.rubygems_version = %q{1.3.1}
s.summary = %q{A secure non evaling end user template engine with aesthetic markup.}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
else
end
else
end
end

92
performance/shopify.rb Normal file
View File

@@ -0,0 +1,92 @@
# This profiler run simulates Shopify.
# We are looking in the tests directory for liquid files and render them within the designated layout file.
# We will also export a substantial database to liquid which the templates can render values of.
# All this is to make the benchmark as non syntetic as possible. All templates and tests are lifted from
# direct real-world usage and the profiler measures code that looks very similar to the way it looks in
# Shopify which is likely the biggest user of liquid in the world which something to the tune of several
# million Template#render calls a day.
require 'rubygems'
require 'active_support'
require 'yaml'
require 'digest/md5'
require File.dirname(__FILE__) + '/shopify/liquid'
require File.dirname(__FILE__) + '/shopify/database.rb'
require "ruby-prof" rescue fail("install ruby-prof extension/gem")
class ThemeProfiler
# Load all templates into memory, do this now so that
# we don't profile IO.
def initialize
@tests = Dir[File.dirname(__FILE__) + '/tests/**/*.liquid'].collect do |test|
next if File.basename(test) == 'theme.liquid'
theme_path = File.dirname(test) + '/theme.liquid'
[File.read(test), (File.file?(theme_path) ? File.read(theme_path) : nil), test]
end.compact
end
def profile
RubyProf.measure_mode = RubyProf::WALL_TIME
# Dup assigns because will make some changes to them
assigns = Database.tables.dup
@tests.each do |liquid, layout, template_name|
# Compute page_tempalte outside of profiler run, uninteresting to profiler
html = nil
page_template = File.basename(template_name, File.extname(template_name))
# Profile compiling and rendering both
RubyProf.resume { html = compile_and_render(liquid, layout, assigns, page_template) }
# return the result and the MD5 of the content, this can be used to detect regressions between liquid version
$stdout.puts "* rendered template %s, content: %s" % [template_name, Digest::MD5.hexdigest(html)]
# Uncomment to dump html files to /tmp so that you can inspect for errors
# File.open("/tmp/#{File.basename(template_name)}.html", "w+") { |fp| fp <<html}
end
RubyProf.stop
end
def compile_and_render(template, layout, assigns, page_template)
tmpl = Liquid::Template.new
tmpl.assigns['page_title'] = 'Page title'
tmpl.assigns['template'] = page_template
content_for_layout = tmpl.parse(template).render(assigns)
if layout
assigns['content_for_layout'] = content_for_layout
tmpl.parse(layout).render(assigns)
else
content_for_layout
end
end
end
profiler = ThemeProfiler.new
puts 'Running profiler...'
results = profiler.profile
puts 'Success'
puts
[RubyProf::FlatPrinter, RubyProf::GraphPrinter, RubyProf::GraphHtmlPrinter].each do |klass|
filename = (ENV['TMP'] || '/tmp') + (klass.name.include?('Html') ? "/liquid.#{klass.name.downcase}.html" : "/liquid.#{klass.name.downcase}.txt")
filename.gsub!(/:+/, '_')
File.open(filename, "w+") { |fp| klass.new(results).print(fp) }
$stderr.puts "wrote #{klass.name} output to #{filename}"
end

View File

@@ -0,0 +1,33 @@
class CommentForm < Liquid::Block
Syntax = /(#{Liquid::VariableSignature}+)/
def initialize(tag_name, markup, tokens)
if markup =~ Syntax
@variable_name = $1
@attributes = {}
else
raise SyntaxError.new("Syntax Error in 'comment_form' - Valid syntax: comment_form [article]")
end
super
end
def render(context)
article = context[@variable_name]
context.stack do
context['form'] = {
'posted_successfully?' => context.registers[:posted_successfully],
'errors' => context['comment.errors'],
'author' => context['comment.author'],
'email' => context['comment.email'],
'body' => context['comment.body']
}
wrap_in_form(article, render_all(@nodelist, context))
end
end
def wrap_in_form(article, input)
%Q{<form id="article-#{article.id}-comment-form" class="comment-form" method="post" action="">\n#{input}\n</form>}
end
end

View File

@@ -0,0 +1,45 @@
require 'yaml'
module Database
# Load the standard vision toolkit database and re-arrage it to be simply exportable
# to liquid as assigns. All this is based on Shopify
def self.tables
@tables ||= begin
db = YAML.load_file(File.dirname(__FILE__) + '/vision.database.yml')
# From vision source
db['products'].each do |product|
collections = db['collections'].find_all do |collection|
collection['products'].any? { |p| p['id'].to_i == product['id'].to_i }
end
product['collections'] = collections
end
# key the tables by handles, as this is how liquid expects it.
db = db.inject({}) do |assigns, (key, values)|
assigns[key] = values.inject({}) { |h, v| h[v['handle']] = v; h; }
assigns
end
# Some standard direct accessors so that the specialized templates
# render correctly
db['collection'] = db['collections'].values.first
db['product'] = db['products'].values.first
db['blog'] = db['blogs'].values.first
db['article'] = db['blog']['articles'].first
db['cart'] = {
'total_price' => db['line_items'].values.inject(0) { |sum, item| sum += item['line_price'] * item['quantity'] },
'item_count' => db['line_items'].values.inject(0) { |sum, item| sum += item['quantity'] },
'items' => db['line_items'].values
}
db
end
end
end
if __FILE__ == $0
p Database.tables['collections']['frontpage'].keys
#p Database.tables['blog']['articles']
end

View File

@@ -0,0 +1,7 @@
module JsonFilter
def json(object)
object.reject {|k,v| k == "collections" }.to_json
end
end

View File

@@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/../../lib/liquid'
require File.dirname(__FILE__) + '/comment_form'
require File.dirname(__FILE__) + '/paginate'
require File.dirname(__FILE__) + '/json_filter'
require File.dirname(__FILE__) + '/money_filter'
require File.dirname(__FILE__) + '/shop_filter'
require File.dirname(__FILE__) + '/tag_filter'
require File.dirname(__FILE__) + '/weight_filter'
Liquid::Template.register_tag 'paginate', Paginate
Liquid::Template.register_tag 'form', CommentForm
Liquid::Template.register_filter JsonFilter
Liquid::Template.register_filter MoneyFilter
Liquid::Template.register_filter WeightFilter
Liquid::Template.register_filter ShopFilter
Liquid::Template.register_filter TagFilter

View File

@@ -0,0 +1,18 @@
module MoneyFilter
def money_with_currency(money)
return '' if money.nil?
sprintf("$ %.2f USD", money/100.0)
end
def money(money)
return '' if money.nil?
sprintf("$ %.2f", money/100.0)
end
private
def currency
ShopDrop.new.currency
end
end

View File

@@ -0,0 +1,93 @@
class Paginate < Liquid::Block
Syntax = /(#{Liquid::QuotedFragment})\s*(by\s*(\d+))?/
def initialize(tag_name, markup, tokens)
@nodelist = []
if markup =~ Syntax
@collection_name = $1
@page_size = if $2
$3.to_i
else
20
end
@attributes = { 'window_size' => 3 }
markup.scan(Liquid::TagAttributes) do |key, value|
@attributes[key] = value
end
else
raise SyntaxError.new("Syntax Error in tag 'paginate' - Valid syntax: paginate [collection] by number")
end
super
end
def render(context)
@context = context
context.stack do
current_page = context['current_page'].to_i
pagination = {
'page_size' => @page_size,
'current_page' => 5,
'current_offset' => @page_size * 5
}
context['paginate'] = pagination
collection_size = context[@collection_name].size
raise ArgumentError.new("Cannot paginate array '#{@collection_name}'. Not found.") if collection_size.nil?
page_count = (collection_size.to_f / @page_size.to_f).to_f.ceil + 1
pagination['items'] = collection_size
pagination['pages'] = page_count -1
pagination['previous'] = link('&laquo; Previous', current_page-1 ) unless 1 >= current_page
pagination['next'] = link('Next &raquo;', current_page+1 ) unless page_count <= current_page+1
pagination['parts'] = []
hellip_break = false
if page_count > 2
1.upto(page_count-1) do |page|
if current_page == page
pagination['parts'] << no_link(page)
elsif page == 1
pagination['parts'] << link(page, page)
elsif page == page_count -1
pagination['parts'] << link(page, page)
elsif page <= current_page - @attributes['window_size'] or page >= current_page + @attributes['window_size']
next if hellip_break
pagination['parts'] << no_link('&hellip;')
hellip_break = true
next
else
pagination['parts'] << link(page, page)
end
hellip_break = false
end
end
render_all(@nodelist, context)
end
end
private
def no_link(title)
{ 'title' => title, 'is_link' => false}
end
def link(title, page)
{ 'title' => title, 'url' => current_url + "?page=#{page}", 'is_link' => true}
end
def current_url
"/collections/frontpage"
end
end

View File

@@ -0,0 +1,98 @@
module ShopFilter
def asset_url(input)
"/files/1/[shop_id]/[shop_id]/assets/#{input}"
end
def global_asset_url(input)
"/global/#{input}"
end
def shopify_asset_url(input)
"/shopify/#{input}"
end
def script_tag(url)
%(<script src="#{url}" type="text/javascript"></script>)
end
def stylesheet_tag(url, media="all")
%(<link href="#{url}" rel="stylesheet" type="text/css" media="#{media}" />)
end
def link_to(link, url, title="")
%|<a href="#{url}" title="#{title}">#{link}</a>|
end
def img_tag(url, alt="")
%|<img src="#{url}" alt="#{alt}" />|
end
def link_to_vendor(vendor)
if vendor
link_to vendor, url_for_vendor(vendor), vendor
else
'Unknown Vendor'
end
end
def link_to_type(type)
if type
link_to type, url_for_type(type), type
else
'Unknown Vendor'
end
end
def url_for_vendor(vendor_title)
"/collections/#{vendor_title.to_handle}"
end
def url_for_type(type_title)
"/collections/#{type_title.to_handle}"
end
def product_img_url(url, style = 'small')
unless url =~ /^products\/([\w\-\_]+)\.(\w{2,4})/
raise ArgumentError, 'filter "size" can only be called on product images'
end
case style
when 'original'
return '/files/shops/random_number/' + url
when 'grande', 'large', 'medium', 'small', 'thumb', 'icon'
"/files/shops/random_number/products/#{$1}_#{style}.#{$2}"
else
raise ArgumentError, 'valid parameters for filter "size" are: original, grande, large, medium, small, thumb and icon '
end
end
def default_pagination(paginate)
html = []
html << %(<span class="prev">#{link_to(paginate['previous']['title'], paginate['previous']['url'])}</span>) if paginate['previous']
for part in paginate['parts']
if part['is_link']
html << %(<span class="page">#{link_to(part['title'], part['url'])}</span>)
elsif part['title'].to_i == paginate['current_page'].to_i
html << %(<span class="page current">#{part['title']}</span>)
else
html << %(<span class="deco">#{part['title']}</span>)
end
end
html << %(<span class="next">#{link_to(paginate['next']['title'], paginate['next']['url'])}</span>) if paginate['next']
html.join(' ')
end
# Accepts a number, and two words - one for singular, one for plural
# Returns the singular word if input equals 1, otherwise plural
def pluralize(input, singular, plural)
input == 1 ? singular : plural
end
end

View File

@@ -0,0 +1,25 @@
module TagFilter
def link_to_tag(label, tag)
"<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tag}\">#{label}</a>"
end
def highlight_active_tag(tag, css_class='active')
if @context['current_tags'].include?(tag)
"<span class=\"#{css_class}\">#{tag}</span>"
else
tag
end
end
def link_to_add_tag(label, tag)
tags = (@context['current_tags'] + [tag]).uniq
"<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tags.join("+")}\">#{label}</a>"
end
def link_to_remove_tag(label, tag)
tags = (@context['current_tags'] - [tag]).uniq
"<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tags.join("+")}\">#{label}</a>"
end
end

View File

@@ -0,0 +1,945 @@
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Variants
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
product_variants:
- &product-1-var-1
id: 1
title: 151cm / Normal
price: 19900
weight: 1000
compare_at_price: 49900
available: true
inventory_quantity: 5
option1: 151cm
option2: Normal
option3:
- &product-1-var-2
id: 2
title: 155cm / Normal
price: 31900
weight: 1000
compare_at_price: 50900
available: true
inventory_quantity: 2
option1: 155cm
option2: Normal
option3:
- &product-2-var-1
id: 3
title: 162cm
price: 29900
weight: 1000
compare_at_price: 52900
available: true
inventory_quantity: 3
option1: 162cm
option2:
option3:
- &product-3-var-1
id: 4
title: 159cm
price: 19900
weight: 1000
compare_at_price:
available: true
inventory_quantity: 4
option1: 159cm
option2:
option3:
- &product-4-var-1
id: 5
title: 159cm
price: 19900
weight: 1000
compare_at_price: 32900
available: true
inventory_quantity: 6
option1: 159cm
option2:
option3:
- &product-1-var-3
id: 6
title: 158cm / Wide
price: 23900
weight: 1000
compare_at_price: 99900
available: false
inventory_quantity: 0
option1: 158cm
option2: Wide
option3:
- &product-3-var-2
id: 7
title: 162cm
price: 19900
weight: 1000
compare_at_price:
available: false
inventory_quantity: 0
option1: 162cm
option2:
option3:
- &product-3-var-3
id: 8
title: 165cm
price: 22900
weight: 1000
compare_at_price:
available: true
inventory_quantity: 4
option1: 165cm
option2:
option3:
- &product-5-var-1
id: 9
title: black / 42
price: 11900
weight: 500
compare_at_price: 22900
available: true
inventory_quantity: 1
option1: black
option2: 42
option3:
- &product-5-var-2
id: 10
title: beige / 42
price: 11900
weight: 500
compare_at_price: 22900
available: true
inventory_quantity: 3
option1: beige
option2: 42
option3:
- &product-5-var-3
id: 11
title: white / 42
price: 13900
weight: 500
compare_at_price: 24900
available: true
inventory_quantity: 1
option1: white
option2: 42
option3:
- &product-5-var-4
id: 12
title: black / 44
price: 11900
weight: 500
compare_at_price: 22900
available: true
inventory_quantity: 2
option1: black
option2: 44
option3:
- &product-5-var-5
id: 13
title: beige / 44
price: 11900
weight: 500
compare_at_price: 22900
available: false
inventory_quantity: 0
option1: beige
option2: 44
option3:
- &product-5-var-6
id: 14
title: white / 44
price: 13900
weight: 500
compare_at_price: 24900
available: false
inventory_quantity: 0
option1: white
option2: 44
option3:
- &product-6-var-1
id: 15
title: red
price: 2179500
weight: 200000
compare_at_price:
available: true
inventory_quantity: 0
option1: red
option2:
option3:
- &product-7-var-1
id: 16
title: black / small
price: 1900
weight: 200
compare_at_price:
available: true
inventory_quantity: 20
option1: black
option2: small
option3:
- &product-7-var-2
id: 17
title: black / medium
price: 1900
weight: 200
compare_at_price:
available: false
inventory_quantity: 0
option1: black
option2: medium
option3:
- &product-7-var-3
id: 18
title: black / large
price: 1900
weight: 200
compare_at_price:
available: true
inventory_quantity: 10
option1: black
option2: large
option3:
- &product-7-var-4
id: 19
title: black / extra large
price: 1900
weight: 200
compare_at_price:
available: false
inventory_quantity: 0
option1: black
option2: extra large
option3:
- &product-8-var-1
id: 20
title: brown / small
price: 5900
weight: 400
compare_at_price: 6900
available: true
inventory_quantity: 5
option1: brown
option2: small
option3:
- &product-8-var-2
id: 21
title: brown / medium
price: 5900
weight: 400
compare_at_price: 6900
available: false
inventory_quantity: 0
option1: brown
option2: medium
option3:
- &product-8-var-3
id: 22
title: brown / large
price: 5900
weight: 400
compare_at_price: 6900
available: true
inventory_quantity: 10
option1: brown
option2: large
option3:
- &product-8-var-4
id: 23
title: black / small
price: 5900
weight: 400
compare_at_price: 6900
available: true
inventory_quantity: 10
option1: black
option2: small
option3:
- &product-8-var-5
id: 24
title: black / medium
price: 5900
weight: 400
compare_at_price: 6900
available: true
inventory_quantity: 10
option1: black
option2: medium
option3:
- &product-8-var-6
id: 25
title: black / large
price: 5900
weight: 400
compare_at_price: 6900
available: false
inventory_quantity: 0
option1: black
option2: large
option3:
- &product-9-var-1
id: 26
title: Body Only
price: 499995
weight: 2000
compare_at_price:
available: true
inventory_quantity: 3
option1: Body Only
option2:
option3:
- &product-9-var-2
id: 27
title: Kit with 18-55mm VR lens
price: 523995
weight: 2000
compare_at_price:
available: true
inventory_quantity: 2
option1: Kit with 18-55mm VR lens
option2:
option3:
- &product-9-var-3
id: 28
title: Kit with 18-200 VR lens
price: 552500
weight: 2000
compare_at_price:
available: true
inventory_quantity: 3
option1: Kit with 18-200 VR lens
option2:
option3:
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Products
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
products:
- &product-1
id: 1
title: Arbor Draft
handle: arbor-draft
type: Snowboards
vendor: Arbor
price: 23900
price_max: 31900
price_min: 23900
price_varies: true
available: true
tags:
- season2005
- pro
- intermediate
- wooden
- freestyle
options:
- Length
- Style
compare_at_price: 49900
compare_at_price_max: 50900
compare_at_price_min: 49900
compare_at_price_varies: true
url: /products/arbor-draft
featured_image: products/arbor_draft.jpg
images:
- products/arbor_draft.jpg
description:
The Arbor Draft snowboard wouldn't exist if Polynesians hadn't figured out how to surf hundreds of years ago. But the Draft does exist, and it's here to bring your urban and park riding to a new level. The board's freaky Tiki design pays homage to culture that inspired snowboarding. It's designed to spin with ease, land smoothly, lock hook-free onto rails, and take the abuse of a pavement pounding or twelve. The Draft will pop off kickers with authority and carve solidly across the pipe. The Draft features targeted Koa wood die cuts inlayed into the deck that enhance the flex pattern. Now bow down to riding's ancestors.
variants:
- *product-1-var-1
- *product-1-var-2
- *product-1-var-3
- &product-2
id: 2
title: Arbor Element
handle: arbor-element
type: Snowboards
vendor: Arbor
price: 29900
price_max: 29900
price_min: 29900
price_varies: false
available: true
tags:
- season2005
- pro
- wooden
- freestyle
options:
- Length
compare_at_price: 52900
compare_at_price_max: 52900
compare_at_price_min: 52900
compare_at_price_varies: false
url: /products/arbor-element
featured_image: products/element58.jpg
images:
- products/element58.jpg
description:
The Element is a technically advanced all-mountain board for riders who readily transition from one terrain, snow condition, or riding style to another. Its balanced design provides the versatility needed for the true ride-it-all experience. The Element is exceedingly lively, freely initiates, and holds a tight edge at speed. Its structural real-wood topsheet is made with book-matched Koa.
variants:
- *product-2-var-1
- &product-3
id: 3
title: Comic ~ Pastel
handle: comic-pastel
type: Snowboards
vendor: Technine
price: 19900
price_max: 22900
price_min: 19900
tags:
- season2006
- beginner
- intermediate
- freestyle
- purple
options:
- Length
price_varies: true
available: true
compare_at_price:
compare_at_price_max: 0
compare_at_price_min: 0
compare_at_price_varies: false
url: /products/comic-pastel
featured_image: products/technine1.jpg
images:
- products/technine1.jpg
- products/technine2.jpg
- products/technine_detail.jpg
description:
2005 Technine Comic Series Description The Comic series was developed to be the ultimate progressive freestyle board in the Technine line. Dependable edge control and a perfect flex pattern for jumping in the park or out of bounds. Landins and progression will come easy with this board and it will help your riding progress to the next level. Street rails, park jibs, backcountry booters and park jumps, this board will do it all.
variants:
- *product-3-var-1
- *product-3-var-2
- *product-3-var-3
- &product-4
id: 4
title: Comic ~ Orange
handle: comic-orange
type: Snowboards
vendor: Technine
price: 19900
price_max: 19900
price_min: 19900
price_varies: false
available: true
tags:
- season2006
- beginner
- intermediate
- freestyle
- orange
options:
- Length
compare_at_price: 32900
compare_at_price_max: 32900
compare_at_price_min: 32900
compare_at_price_varies: false
url: /products/comic-orange
featured_image: products/technine3.jpg
images:
- products/technine3.jpg
- products/technine4.jpg
description:
2005 Technine Comic Series Description The Comic series was developed to be the ultimate progressive freestyle board in the Technine line. Dependable edge control and a perfect flex pattern for jumping in the park or out of bounds. Landins and progression will come easy with this board and it will help your riding progress to the next level. Street rails, park jibs, backcountry booters and park jumps, this board will do it all.
variants:
- *product-4-var-1
- &product-5
id: 5
title: Burton Boots
handle: burton-boots
type: Boots
vendor: Burton
price: 11900
price_max: 11900
price_min: 11900
price_varies: false
available: true
tags:
- season2006
- beginner
- intermediate
- boots
options:
- Color
- Shoe Size
compare_at_price: 22900
compare_at_price_max: 22900
compare_at_price_min: 22900
compare_at_price_varies: false
url: /products/burton-boots
featured_image: products/burton.jpg
images:
- products/burton.jpg
description:
The Burton boots are particularly well on snowboards. The very best thing about them is that the according picture is cubic. This makes testing in a Vision testing environment very easy.
variants:
- *product-5-var-1
- *product-5-var-2
- *product-5-var-3
- *product-5-var-4
- *product-5-var-5
- *product-5-var-6
- &product-6
id: 6
title: Superbike 1198 S
handle: superbike
type: Superbike
vendor: Ducati
price: 2179500
price_max: 2179500
price_min: 2179500
price_varies: false
available: true
tags:
- ducati
- superbike
- bike
- street
- racing
- performance
options:
- Color
compare_at_price:
compare_at_price_max: 0
compare_at_price_min: 0
compare_at_price_varies: false
url: /products/superbike
featured_image: products/ducati.jpg
images:
- products/ducati.jpg
description:
<h3>S PERFORMANCE</h3>
<p>Producing 170hp (125kW) and with a dry weight of just 169kg (372.6lb), the new 1198 S now incorporates more World Superbike technology than ever before by taking the 1198 motor and adding top-of-the-range suspension, lightweight chassis components and a true racing-style traction control system designed for road use.</p>
<p>The high performance, fully adjustable 43mm Öhlins forks, which sport low friction titanium nitride-treated fork sliders, respond effortlessly to every imperfection in the tarmac. Beyond their advanced engineering solutions, one of the most important characteristics of Öhlins forks is their ability to communicate the condition and quality of the tyre-to-road contact patch, a feature that puts every rider in superior control. The suspension set-up at the rear is complemented with a fully adjustable Öhlins rear shock equipped with a ride enhancing top-out spring and mounted to a single-sided swingarm for outstanding drive and traction. The front-to-rear Öhlins package is completed with a control-enhancing adjustable steering damper.</p>
variants:
- *product-6-var-1
- &product-7
id: 7
title: Shopify Shirt
handle: shopify-shirt
type: Shirt
vendor: Shopify
price: 1900
price_max: 1900
price_min: 1900
price_varies: false
available: true
tags:
- shopify
- shirt
- apparel
- tshirt
- clothing
options:
- Color
- Size
compare_at_price:
compare_at_price_max: 0
compare_at_price_min: 0
compare_at_price_varies: false
url: /products/shopify-shirt
featured_image: products/shopify_shirt.png
images:
- products/shopify_shirt.png
description:
<p>High Quality Shopify Shirt. Wear your e-commerce solution with pride and attract attention anywhere you go.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
variants:
- *product-7-var-1
- *product-7-var-2
- *product-7-var-3
- *product-7-var-4
- &product-8
id: 8
title: Hooded Sweater
handle: hooded-sweater
type: Sweater
vendor: Stormtech
price: 5900
price_max: 5900
price_min: 5900
price_varies: false
available: true
tags:
- sweater
- hooded
- apparel
- clothing
options:
- Color
- Size
compare_at_price: 6900
compare_at_price_max: 6900
compare_at_price_min: 6900
compare_at_price_varies: false
url: /products/hooded-sweater
featured_image: products/hooded-sweater.jpg
images:
- products/hooded-sweater.jpg
- products/hooded-sweater-b.jpg
description:
<p>Extra comfortable zip up sweater. Durable quality, ideal for any outdoor activities.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
variants:
- *product-8-var-1
- *product-8-var-2
- *product-8-var-3
- *product-8-var-4
- *product-8-var-5
- *product-8-var-6
- &product-9
id: 9
title: D3 Digital SLR Camera
handle: d3
type: SLR
vendor: Nikon
price: 499995
price_max: 552500
price_min: 499995
price_varies: true
available: true
tags:
- camera
- slr
- nikon
- professional
options:
- Bundle
compare_at_price:
compare_at_price_max: 0
compare_at_price_min: 0
compare_at_price_varies: false
url: /products/d3
featured_image: products/d3.jpg
images:
- products/d3.jpg
- products/d3_2.jpg
- products/d3_3.jpg
description:
<p>Flagship pro D-SLR with a 12.1-MP FX-format CMOS sensor, blazing 9 fps shooting at full FX resolution and low-noise performance up to 6400 ISO.</p>
<p><strong>Nikon's original 12.1-megapixel FX-format (23.9 x 36mm) CMOS sensor:</strong> Couple Nikon's exclusive digital image processing system with the 12.1-megapixel FX-format and you'll get breathtakingly rich images while also reducing noise to unprecedented levels with even higher ISOs.</p>
<p><strong>Continuous shooting at up to 9 frames per second:</strong> At full FX resolution and up to 11fps in the DX crop mode, the D3 offers uncompromised shooting speeds for fast-action and sports photography.</p>
variants:
- *product-9-var-1
- *product-9-var-2
- *product-9-var-3
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Line Items
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
line_items:
- &line_item-1
id: 1
title: 'Arbor Draft'
subtitle: '151cm'
price: 29900
line_price: 29900
quantity: 1
variant: *product-1-var-1
product: *product-1
- &line_item-2
id: 2
title: 'Comic ~ Orange'
subtitle: '159cm'
price: 19900
line_price: 39800
quantity: 2
variant: *product-4-var-1
product: *product-4
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Link Lists
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
links:
- &link-1
id: 1
title: Our Sale
url: /collections/sale
- &link-2
id: 2
title: Arbor Stuff
url: /collections/arbor
- &link-3
id: 3
title: All our Snowboards
url: /collections/snowboards
- &link-4
id: 4
title: Powered by Shopify
url: 'http://shopify.com'
- &link-5
id: 5
title: About Us
url: /pages/about-us
- &link-6
id: 6
title: Policies
url: /pages/shipping
- &link-7
id: 7
title: Contact Us
url: /pages/contact
- &link-8
id: 8
title: Our blog
url: /blogs/bigcheese-blog
- &link-9
id: 9
title: New Boots
url: /products/burton-boots
- &link-10
id: 10
title: Paginated Sale
url: /collections/paginated-sale
- &link-11
id: 11
title: Our Paginated blog
url: /blogs/paginated-blog
- &link-12
id: 12
title: Catalog
url: /collections/all
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Link Lists
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
link_lists:
- &link-list-1
id: 1
title: 'Main Menu'
handle: 'main-menu'
links:
- *link-12
- *link-5
- *link-7
- *link-8
- &link-list-2
id: 1
title: 'Footer Menu'
handle: 'footer'
links:
- *link-5
- *link-6
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Collections
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
collections:
- &collection-1
id: 1
title: Frontpage
handle: frontpage
url: /collections/frontpage
products:
- *product-7
- *product-8
- *product-9
- &collection-2
id: 2
title: Arbor
handle: arbor
url: /collections/arbor
products:
- *product-1
- *product-2
- &collection-3
id: 3
title: Snowboards
handle: snowboards
url: /collections/snowboards
description:
<p>This is a description for my <strong>Snowboards</strong> collection.</p>
products:
- *product-1
- *product-2
- *product-3
- *product-4
- &collection-4
id: 4
title: Items On Sale
handle: sale
url: /collections/sale
products:
- *product-1
- &collection-5
id: 5
title: Paginated Sale
handle: 'paginated-sale'
url: '/collections/paginated-sale'
products:
- *product-1
- *product-2
- *product-3
- *product-4
products_count: 210
- &collection-6
id: 6
title: All products
handle: 'all'
url: '/collections/all'
products:
- *product-7
- *product-8
- *product-9
- *product-6
- *product-1
- *product-2
- *product-3
- *product-4
- *product-5
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Pages and Blogs
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
pages:
- &page-2
id: 1
title: Contact Us
handle: contact
url: /pages/contact
author: Tobi
content:
"<p>You can contact us via phone under (555) 567-2222.</p>
<p>Our retail store is located at <em>Rue d'Avignon 32, Avignon (Provence)</em>.</p>
<p><strong>Opening Hours:</strong><br />Monday through Friday: 9am - 6pm<br />Saturday: 10am - 3pm<br />Sunday: closed</p>"
created_at: 2005-04-04 12:00
- &page-3
id: 2
title: About Us
handle: about-us
url: /pages/about-us
author: Tobi
content:
"<p>Our company was founded in 1894 and we are since operating out of Avignon from the beautiful Provence.</p>
<p>We offer the highest quality products and are proud to serve our customers to their heart's content.</p>"
created_at: 2005-04-04 12:00
- &page-4
id: 3
title: Shopping Cart
handle: shopping-cart
url: /pages/shopping-cart
author: Tobi
content: "<ul><li>Your order is safe with us. Our checkout uses industry standard security to protect your information.</li><li>Your order will be billed immediately upon checkout.</li><li><b>ALL SALES ARE FINAL:</b> Defective or damaged product will be exchanged</li><li>All orders are processed expediently: usually in under 24 hours.</li></ul>"
created_at: 2005-04-04 12:00
- &page-5
id: 4
title: Shipping and Handling
handle: shipping
url: /pages/shipping
author: Tobi
content: <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
created_at: 2005-04-04 12:00
- &page-6
id: 5
title: Frontpage
handle: frontpage
url: /pages/frontpage
author: Tobi
content: <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
created_at: 2005-04-04 12:00
blogs:
- id: 1
handle: news
title: News
url: /blogs/news
articles:
- id: 3
title: 'Welcome to the new Foo Shop'
author: Daniel
content: <p><strong>Welcome to your Shopify store! The jaded Pixel crew is really glad you decided to take Shopify for a spin.</strong></p><p>To help you get you started with Shopify, here are a couple of tips regarding what you see on this page.</p><p>The text you see here is an article. To edit this article, create new articles or create new pages you can go to the <a href="/admin/pages">Blogs &amp; Pages</a> tab of the administration menu.</p><p>The Shopify t-shirt above is a product and selling products is what Shopify is all about. To edit this product, or create new products you can go to the <a href="/admin/products">Products Tab</a> in of the administration menu.</p><p>While you're looking around be sure to check out the <a href="/admin/collections">Collections</a> and <a href="/admin/links">Navigations</a> tabs and soon you will be well on your way to populating your site.</p><p>And of course don't forget to browse the <a href="admin/design/appearance/themes">theme gallery</a> to pick a new look for your shop!</p><p><strong>Shopify is in beta</strong><br />If you would like to make comments or suggestions please visit us in the <a href="http://forums.shopify.com/community">Shopify Forums</a> or drop us an <a href="mailto:feedback@shopify.com">email</a>.</p>
created_at: 2005-04-04 16:00
- id: 4
title: 'Breaking News: Restock on all sales products'
author: Tobi
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-04 12:00
articles_count: 2
- id: 2
handle: bigcheese-blog
title: Bigcheese blog
url: /blogs/bigcheese-blog
articles:
- id: 1
title: 'One thing you probably did not know yet...'
author: Justin
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-04 16:00
comments:
-
id: 1
author: John Smith
email: john@smith.com
content: Wow...great article man.
status: published
created_at: 2009-01-01 12:00
updated_at: 2009-02-01 12:00
url: ""
-
id: 2
author: John Jones
email: john@jones.com
content: I really enjoyed this article. And I love your shop! It's awesome. Shopify rocks!
status: published
created_at: 2009-03-01 12:00
updated_at: 2009-02-01 12:00
url: "http://somesite.com/"
- id: 2
title: Fascinating
author: Tobi
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-06 12:00
comments:
articles_count: 2
comments_enabled?: true
comment_post_url: ""
comments_count: 2
moderated?: true
- id: 3
handle: paginated-blog
title: Paginated blog
url: /blogs/paginated-blog
articles:
- id: 6
title: 'One thing you probably did not know yet...'
author: Justin
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-04 16:00
- id: 7
title: Fascinating
author: Tobi
content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
created_at: 2005-04-06 12:00
articles_count: 200

View File

@@ -0,0 +1,11 @@
module WeightFilter
def weight(grams)
sprintf("%.2f", grams / 1000)
end
def weight_with_unit(grams)
"#{weight(grams)} kg"
end
end

View File

@@ -0,0 +1,74 @@
<div class="article">
<h2 class="article-title">{{ article.title }}</h2>
<p class="article-details">posted <span class="article-time">{{ article.created_at | date: "%Y %h" }}</span> by <span class="article-author">{{ article.author }}</span></p>
<div class="article-body textile">
{{ article.content }}
</div>
</div>
<!-- Comments -->
{% if blog.comments_enabled? %}
<div id="comments">
<h3>Comments</h3>
<!-- List all comments -->
<ul id="comment-list">
{% for comment in article.comments %}
<li>
<div class="comment-details">
<span class="comment-author">{{ comment.author }}</span> said on <span class="comment-date">{{ comment.created_at | date: "%B %d, %Y" }}</span>:
</div>
<div class="comment">
{{ comment.content }}
</div>
</li>
{% endfor %}
</ul>
<!-- Comment Form -->
<div id="comment-form">
{% form article %}
<h3>Leave a comment</h3>
<!-- Check if a comment has been submitted in the last request, and if yes display an appropriate message -->
{% if form.posted_successfully? %}
{% if blog.moderated? %}
<div class="notice">
Successfully posted your comment.<br />
It will have to be approved by the blog owner first before showing up.
</div>
{% else %}
<div class="notice">Successfully posted your comment.</div>
{% endif %}
{% endif %}
{% if form.errors %}
<div class="notice error">Not all the fields have been filled out correctly!</div>
{% endif %}
<dl>
<dt class="{% if form.errors contains 'author' %}error{% endif %}"><label for="comment_author">Your name</label></dt>
<dd><input type="text" id="comment_author" name="comment[author]" size="40" value="{{form.author}}" class="{% if form.errors contains 'author' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'email' %}error{% endif %}"><label for="comment_email">Your email</label></dt>
<dd><input type="text" id="comment_email" name="comment[email]" size="40" value="{{form.email}}" class="{% if form.errors contains 'email' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'body' %}error{% endif %}"><label for="comment_body">Your comment</label></dt>
<dd><textarea id="comment_body" name="comment[body]" cols="40" rows="5" class="{% if form.errors contains 'body' %}input-error{% endif %}">{{form.body}}</textarea></dd>
</dl>
{% if blog.moderated? %}
<p class="hint">comments have to be approved before showing up</p>
{% endif %}
<input type="submit" value="Post comment" id="comment-submit" />
{% endform %}
</div>
<!-- END Comment Form -->
</div>
{% endif %}
<!-- END Comments -->

View File

@@ -0,0 +1,33 @@
<div id="page">
<h2>{{page.title}}</h2>
{% paginate blog.articles by 20 %}
{% for article in blog.articles %}
<div class="article">
<div class="headline">
<h3 class="title">
<a href="{{article.url}}">{{ article.title }}</a>
</h3>
<h4 class="date">Posted on {{ article.created_at | date: "%B %d, '%y" }} by {{ article.author }}.</h4>
</div>
<div class="article-body textile">
{{ article.content | strip_html | truncate: 250 }}
</div>
{% if blog.comments_enabled? %}
<p style="text-align: right"><a href="{{article.url}}#comments">{{ article.comments_count }} comments</a></p>
{% endif %}
</div>
{% endfor %}
<div id="pagination">
{{ paginate | default_pagination }}
</div>
{% endpaginate %}
</div>

View File

@@ -0,0 +1,66 @@
<script type="text/javascript">
function remove_item(id) {
document.getElementById('updates_'+id).value = 0;
document.getElementById('cartform').submit();
}
</script>
<div>
{% if cart.item_count == 0 %}
<h4>Your shopping cart is looking rather empty...</h4>
{% else %}
<form action="/cart" method="post" id="cartform">
<div id="cart">
<h3>You have {{ cart.item_count }} {{ cart.item_count | pluralize: 'product', 'products' }} in here!</h3>
<ul id="line-items">
{% for item in cart.items %}
<li id="item-{{item.id}}" class="clearfix">
<div class="thumb">
<div class="prodimage">
<a href="{{item.product.url}}" title="View {{item.title}} Page"><img src="{{item.product.featured_image | product_img_url: 'thumb' }}" alt="{{item.title | escape }}" /></a>
</div></div>
<h3 style="padding-right: 150px">
<a href="{{item.product.url}}" title="View {{item.title | escape }} Page">
{{ item.title }}
{% if item.variant.available == true %}
({{item.variant.title}})
{% endif %}
</a>
</h3>
<small class="itemcost">Costs {{ item.price | money }} each, <span class="money">{{item.line_price | money }}</span> total.</small>
<p class="right">
<label for="updates">How many? </label>
<input type="text" size="4" name="updates[{{item.variant.id}}]" id="updates_{{item.variant.id}}" value="{{item.quantity}}" onfocus="this.select();"/><br />
<a href="#" onclick="remove_item({{item.variant.id}}); return false;" class="remove"><img style="padding:15px 0 0 0;margin:0;" src="{{ 'delete.gif' | asset_url }}" /></a>
</p>
</li>
{% endfor %}
<li id="total">
<input type="image" id="update-cart" name="update" value="Update My Cart" src="{{ 'update.gif' | asset_url }}" />
Subtotal:
<span class="money">{{ cart.total_price | money_with_currency }}</span>
</li>
</ul>
</div>
<div class="info">
<input type="image" value="Checkout!" name="checkout" src="{{ 'checkout.gif' | asset_url }}" />
</div>
{% if additional_checkout_buttons %}
<div class="additional-checkout-buttons">
<p>- or -</p>
{{ content_for_additional_checkout_buttons }}
</div>
{% endif %}
</form>
{% endif %}
</div>

View File

@@ -0,0 +1,22 @@
{% paginate collection.products by 20 %}
<ul id="product-collection">
{% for product in collection.products %}
<li class="singleproduct clearfix">
<div class="small">
<div class="prodimage"><a href="{{product.url}}"><img src="{{ product.featured_image | product_img_url: 'small' }}" /></a></div>
</div>
<div class="description">
<h3><a href="{{product.url}}">{{product.title}}</a></h3>
<p>{{ product.description | strip_html | truncatewords: 35 }}</p>
<p class="money">{{ product.price_min | money }}{% if product.price_varies %} - {{ product.price_max | money }}{% endif %}</p>
</div>
</li>
{% endfor %}
</ul>
<div id="pagination">
{{ paginate | default_pagination }}
</div>
{% endpaginate %}

View File

@@ -0,0 +1,47 @@
<div id="frontproducts"><div id="frontproducts-top"><div id="frontproducts-bottom">
<h2 style="display: none;">Featured Items</h2>
{% for product in collections.frontpage.products limit:1 offset:0 %}
<div class="productmain">
<a href="{{ product.url }}"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}" /></a>
<h3><a href="{{ product.url }}">{{ product.title }}</a></h3>
<div class="description">{{ product.description | strip_html | truncatewords: 18 }}</div>
<p class="money">{{ product.price_min | money }}</p>
</div>
{% endfor %}
{% for product in collections.frontpage.products offset:1 %}
<div class="product">
<a href="{{ product.url }}"><img src="{{ product.featured_image | product_img_url: 'thumb' }}" alt="{{ product.title | escape }}" /></a>
<h3><a href="{{ product.url }}">{{ product.title }}</a></h3>
<p class="money">{{ product.price_min | money }}</p>
</div>
{% endfor %}
</div></div></div>
<div id="mainarticle">
{% assign article = pages.frontpage %}
{% if article.content != "" %}
<h2>{{ article.title }}</h2>
<div class="article-body textile">
{{ article.content }}
</div>
{% else %}
<div class="article-body textile">
In <em>Admin &gt; Blogs &amp; Pages</em>, create a page with the handle <strong><code>frontpage</code></strong> and it will show up here.<br />
{{ "Learn more about handles" | link_to "http://wiki.shopify.com/Handle" }}
</div>
{% endif %}
</div>
<br style="clear: both;" />
<div id="articles">
{% for article in blogs.news.articles offset:1 %}
<div class="article">
<h2>{{ article.title }}</h2>
<div class="article-body textile">
{{ article.content }}
</div>
</div>
{% endfor %}
</div>

View File

@@ -0,0 +1,8 @@
<div id="page">
<h2>{{page.title}}</h2>
<div class="article textile">
{{page.content}}
</div>
</div>

View File

@@ -0,0 +1,68 @@
<div id="productpage">
<div id="productimages"><div id="productimages-top"><div id="productimages-bottom">
{% for image in product.images %}
{% if forloop.first %}
<a href="{{ image | product_img_url: 'large' }}" class="productimage" rel="lightbox">
<img src="{{ image | product_img_url: 'medium'}}" alt="{{product.title | escape }}" />
</a>
{% else %}
<a href="{{ image | product_img_url: 'large' }}" class="productimage-small" rel="lightbox">
<img src="{{ image | product_img_url: 'small'}}" alt="{{product.title | escape }}" />
</a>
{% endif %}
{% endfor %}
</div></div></div>
<h2>{{ product.title }}</h2>
<ul id="details" class="hlist">
<li>Vendor: {{ product.vendor | link_to_vendor }}</li>
<li>Type: {{ product.type | link_to_type }}</li>
</ul>
<small>{{ product.price_min | money }}{% if product.price_varies %} - {{ product.price_max | money }}{% endif %}</small>
<div id="variant-add">
<form action="/cart/add" method="post">
<select id="variant-select" name="id" class="product-info-options">
{% for variant in product.variants %}
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>
{% endfor %}
</select>
<div id="price-field" class="price"></div>
<div style="text-align:center;"><input type="image" name="add" value="Add to Cart" id="add" src="{{ 'addtocart.gif' | asset_url }}" /></div>
</form>
</div>
<div class="description textile">
{{ product.description }}
</div>
</div>
<script type="text/javascript">
<!--
// prototype callback for multi variants dropdown selector
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
$('add').removeClassName('disabled'); // remove unavailable class from add-to-cart button
$('add').disabled = false; // reenable add-to-cart button
$('price-field').innerHTML = Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}"); // update price field
} else {
// variant doesn't exist
$('add').addClassName('disabled'); // set add-to-cart button to unavailable class
$('add').disabled = true; // disable add-to-cart button
$('price-field').innerHTML = (variant) ? "Sold Out" : "Unavailable"; // update price-field message
}
};
// initialize multi selector for product
Event.observe(document, 'dom:loaded', function() {
new Shopify.OptionSelectors("variant-select", { product: {{ product | json }}, onVariantSelected: selectCallback });
});
-->
</script>

View File

@@ -0,0 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{shop.name}} - {{page_title}}</title>
{{ 'textile.css' | global_asset_url | stylesheet_tag }}
{{ 'lightbox/v204/lightbox.css' | global_asset_url | stylesheet_tag }}
{{ 'prototype/1.6/prototype.js' | global_asset_url | script_tag }}
{{ 'scriptaculous/1.8.2/scriptaculous.js' | global_asset_url | script_tag }}
{{ 'lightbox/v204/lightbox.js' | global_asset_url | script_tag }}
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{{ 'layout.css' | asset_url | stylesheet_tag }}
{{ 'shop.js' | asset_url | script_tag }}
{{ content_for_header }}
</head>
<body id="page-{{template}}">
<p class="hide"><a href="#rightsiders">Skip to navigation.</a></p>
<!-- mini cart -->
{% if cart.item_count > 0 %}
<div id="minicart" style="display:none;"><div id="minicart-inner">
<div id="minicart-items">
<h2>There {{ cart.item_count | pluralize: 'is', 'are' }} {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} in <a href="/cart" title="View your cart">your cart</a>!</h2><h4 style="font-size: 16px; margin: 0 0 10px 0; padding: 0;">Your subtotal is {{ cart.total_price | money }}.</h4>
{% for item in cart.items %}
<div class="thumb">
<div class="prodimage"><a href="{{item.product.url}}" onMouseover="tooltip('{{ item.quantity }} x {{ item.title }} ({{ item.variant.title }})', 200)"; onMouseout="hidetooltip()"><img src="{{ item.product.featured_image | product_img_url: 'thumb' }}" /></a></div>
</div>
{% endfor %}
</div>
<br style="clear:both;" />
</div></div>
{% endif %}
<div id="container">
<div id="header">
<!-- Begin Header -->
<h1 id="logo"><a href="/" title="Go Home">{{shop.name}}</a></h1>
<div id="cartlinks">
{% if cart.item_count > 0 %}
<h2 id="cartcount"><a href="/cart" onMouseover="tooltip('There {{ cart.item_count | pluralize: 'is', 'are' }} {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} in your cart!', 200)"; onMouseout="hidetooltip()">{{ cart.item_count }} {{ cart.item_count | pluralize: 'thing', 'things' }}!</a></h2>
<a href="/cart" id="minicartswitch" onclick="superSwitch(this, 'minicart', 'Close Mini Cart'); return false;" id="cartswitch">View Mini Cart ({{ cart.total_price | money }})</a>
{% endif %}
</div>
<!-- End Header -->
</div>
<hr />
<div id="main">
<div id="content">
<div id="innercontent">
{{ content_for_layout }}
</div>
</div>
<hr />
<div id="rightsiders">
<ul class="rightlinks">
{% for link in linklists.main-menu.links %}
<li>{{ link.title | link_to: link.url }}</li>
{% endfor %}
</ul>
{% if tags %}
<ul class="rightlinks">
{% for tag in collection.tags %}
<li><span class="add-link">{{ '+' | link_to_add_tag: tag }}</span>{{ tag | highlight_active_tag | link_to_tag: tag }}</li>
{% endfor %}
</ul>
{% endif %}
<ul class="rightlinks">
{% for link in linklists.footer.links %}
<li>{{ link.title | link_to: link.url }}</li>
{% endfor %}
</ul>
</div>
<hr /><br style="clear:both;" />
<div id="footer">
<div class="footerinner">
All prices are in {{ shop.currency }}.
Powered by <a href="http://www.shopify.com" title="Shopify, Hosted E-Commerce">Shopify</a>.
</div>
</div>
</div>
</div>
<div id="tooltip"></div>
<img id="pointer" src="{{ 'arrow2.gif' | asset_url }}" />
</body>
</html>

View File

@@ -0,0 +1,74 @@
<div class="article">
<h2 class="article-title">{{ article.title }}</h2>
<p class="article-details">posted <span class="article-time">{{ article.created_at | date: "%Y %h" }}</span> by <span class="article-author">{{ article.author }}</span></p>
<div class="article-body textile">
{{ article.content }}
</div>
</div>
<!-- Comments -->
{% if blog.comments_enabled? %}
<div id="comments">
<h3>Comments</h3>
<!-- List all comments -->
<ul id="comment-list">
{% for comment in article.comments %}
<li>
<div class="comment">
{{ comment.content }}
</div>
<div class="comment-details">
Posted by {{ comment.author }} on {{ comment.created_at | date: "%B %d, %Y" }}
</div>
</li>
{% endfor %}
</ul>
<!-- Comment Form -->
<div id="comment-form">
{% form article %}
<h3>Leave a comment</h3>
<!-- Check if a comment has been submitted in the last request, and if yes display an appropriate message -->
{% if form.posted_successfully? %}
{% if blog.moderated? %}
<div class="notice">
Successfully posted your comment.<br />
It will have to be approved by the blog owner first before showing up.
</div>
{% else %}
<div class="notice">Successfully posted your comment.</div>
{% endif %}
{% endif %}
{% if form.errors %}
<div class="notice error">Not all the fields have been filled out correctly!</div>
{% endif %}
<dl>
<dt class="{% if form.errors contains 'author' %}error{% endif %}"><label for="comment_author">Your name</label></dt>
<dd><input type="text" id="comment_author" name="comment[author]" size="40" value="{{form.author}}" class="{% if form.errors contains 'author' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'email' %}error{% endif %}"><label for="comment_email">Your email</label></dt>
<dd><input type="text" id="comment_email" name="comment[email]" size="40" value="{{form.email}}" class="{% if form.errors contains 'email' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'body' %}error{% endif %}"><label for="comment_body">Your comment</label></dt>
<dd><textarea id="comment_body" name="comment[body]" cols="40" rows="5" class="{% if form.errors contains 'body' %}input-error{% endif %}">{{form.body}}</textarea></dd>
</dl>
{% if blog.moderated? %}
<p class="hint">comments have to be approved before showing up</p>
{% endif %}
<input type="submit" value="Post comment" id="comment-submit" />
{% endform %}
</div>
<!-- END Comment Form -->
</div>
{% endif %}
<!-- END Comments -->

View File

@@ -0,0 +1,13 @@
<div id="blog-page">
<h2 class="heading-shaded">{{page.title}}</h2>
{% for article in blog.articles %}
<h4>
{{ article.created_at | date: '%d %b' }}
<a href="{{article.url}}">{{ article.title }}</a>
</h4>
{{ article.content }}
{% if blog.comments_enabled? %}
<p><a href="{{article.url}}#comments">{{ article.comments_count }} comments</a></p>
{% endif %}
{% endfor %}
</div>

View File

@@ -0,0 +1,54 @@
<script type="text/javascript">
function remove_item(id) {
document.getElementById('updates_'+id).value = 0;
document.getElementById('cart').submit();
}
</script>
<div id="cart-page">
{% if cart.item_count == 0 %}
<p>Your shopping cart is empty...</p>
<p><a href="/"><img src="{{ 'continue_shopping_icon.gif' | asset_url }}" alt="Continue shopping"/></a><p>
{% else %}
<form action="/cart" method="post" id="cart">
<table class="cart">
<tr>
<th colspan="2">Product</th>
<th class="short">Qty</th>
<th>Price</th>
<th>Total</th>
<th class="short">Remove</th>
</tr>
{% for item in cart.items %}
<tr class="{% cycle 'odd', 'even' %}">
<td class="short">{{ item.product.featured_image | product_img_url: 'thumb' | img_tag }}</td>
<td><a href="{{item.product.url}}">{{ item.title }}</a></td>
<td class="short"><input type="text" class="quantity" name="updates[{{item.variant.id}}]" id="updates_{{item.variant.id}}" value="{{item.quantity}}" onfocus="this.select();"/></td>
<td class="cart-price">{{ item.price | money }}</td>
<td class="cart-price">{{item.line_price | money }}</td>
<td class="short"><a href="#" onclick="remove_item({{item.variant.id}}); return false;" class="remove"><img src="{{ 'cancel_icon.gif' | asset_url }}" alt="Remove" /></a></td>
</tr>
{% endfor %}
</table>
<p class="updatebtn"><input type="image" value="Update Cart" name="update" src="{{ 'update_icon.gif' | asset_url }}" alt="Update" /></p>
<p class="subtotal">
<strong>Subtotal:</strong> {{cart.total_price | money_with_currency }}
</p>
<p class="checkout"><input type="image" src="{{ 'checkout_icon.gif' | asset_url }}" alt="Proceed to Checkout" value="Proceed to Checkout" name="checkout" /></p>
{% if additional_checkout_buttons %}
<div class="additional-checkout-buttons">
<p>- or -</p>
{{ content_for_additional_checkout_buttons }}
</div>
{% endif %}
</form>
{% endif %}
</div>

View File

@@ -0,0 +1,29 @@
<div id="collection-page">
{% if collection.description %}
<div id="collection-description" class="textile">{{ collection.description }}</div>
{% endif %}
{% paginate collection.products by 20 %}
<ul id="product-collection">
{% for product in collection.products %}
<li class="single-product clearfix">
<div class="small">
<div class="prod-image"><a href="{{product.url}}"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}" /></a></div>
</div>
<div class="prod-list-description">
<h3><a href="{{product.url}}">{{product.title}}</a></h3>
<p>{{ product.description | strip_html | truncatewords: 35 }}</p>
<p class="prd-price">{{ product.price_min | money }}{% if product.price_varies %} - {{ product.price_max | money }}{% endif %}</p>
</div>
</li>
{% endfor %}
</ul>
<div id="pagination">
{{ paginate | default_pagination }}
</div>
{% endpaginate %}
</div>

View File

@@ -0,0 +1,32 @@
<div id="home-page">
<h3 class="heading-shaded">Featured products...</h3>
<div class="featured-prod-row clearfix">
{% for product in collections.frontpage.products %}
<div class="featured-prod-item">
<p>
<a href="{{product.url}}"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}"/></a>
</p>
<h4><a href="{{product.url}}">{{product.title}}</a></h4>
{% if product.compare_at_price %}
{% if product.price_min != product.compare_at_price %}
<p class="prd-price">Was:<del>{{product.compare_at_price | money}}</del></p>
<p class="prd-price"><ins>Now: {{product.price_min | money}}</ins></p>
{% endif %}
{% else %}
<p class="prd-price"><ins>{{product.price_min | money}}</ins></p>
{% endif %}
</div>
{% endfor %}
</div>
<div id="articles">
{% assign article = pages.frontpage %}
{% if article.content != "" %}
<h3>{{ article.title }}</h3>
{{ article.content }}
{% else %}
In <em>Admin &gt; Blogs &amp; Pages</em>, create a page with the handle <strong><code>frontpage</code></strong> and it will show up here.<br />
{{ "Learn more about handles" | link_to "http://wiki.shopify.com/Handle" }}
{% endif %}
</div>
</div>

View File

@@ -0,0 +1,4 @@
<div id="single-page">
<h2 class="heading-shaded">{{page.title}}</h2>
{{ page.content }}
</div>

View File

@@ -0,0 +1,75 @@
<div id="product-page">
<h2 class="heading-shaded">{{ product.title }}</h2>
<div id="product-details">
<div id="product-images">
{% for image in product.images %}
{% if forloop.first %}
<a href="{{ image | product_img_url: 'large' }}" class="product-image" rel="lightbox[ product]" title="">
<img src="{{ image | product_img_url: 'medium'}}" alt="{{product.title | escape }}" />
</a>
{% else %}
<a href="{{ image | product_img_url: 'large' }}" class="product-image-small" rel="lightbox[ product]" title="">
<img src="{{ image | product_img_url: 'small'}}" alt="{{product.title | escape }}" />
</a>
{% endif %}
{% endfor %}
</div>
<ul id="product-info">
<li>Vendor: {{ product.vendor | link_to_vendor }}</li>
<li>Type: {{ product.type | link_to_type }}</li>
</ul>
<small>{{ product.price_min | money }}{% if product.price_varies %} - {{ product.price_max | money }}{% endif %}</small>
<div id="product-options">
{% if product.available %}
<form action="/cart/add" method="post">
<select id="product-select" name='id'>
{% for variant in product.variants %}
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>
{% endfor %}
</select>
<div id="price-field"></div>
<div class="add-to-cart"><input type="image" name="add" value="Add to Cart" id="add" src="{{ 'add-to-cart.gif' | asset_url }}" /></div>
</form>
{% else %}
<span>Sold Out!</span>
{% endif %}
</div>
<div class="product-description">
{{ product.description }}
</div>
</div>
</div>
<script type="text/javascript">
<!--
// mootools callback for multi variants dropdown selector
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
$('add').removeClass('disabled'); // remove unavailable class from add-to-cart button
$('add').disabled = false; // reenable add-to-cart button
$('price-field').innerHTML = Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}"); // update price field
} else {
// variant doesn't exist
$('add').addClass('disabled'); // set add-to-cart button to unavailable class
$('add').disabled = true; // disable add-to-cart button
$('price-field').innerHTML = (variant) ? "Sold Out" : "Unavailable"; // update price-field message
}
};
// initialize multi selector for product
window.addEvent('domready', function() {
new Shopify.OptionSelectors("product-select", { product: {{ product | json }}, onVariantSelected: selectCallback });
});
-->
</script>

View File

@@ -0,0 +1,85 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>{{shop.name}} - {{page_title}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{{ 'main.css' | asset_url | stylesheet_tag }}
{{ 'shop.js' | asset_url | script_tag }}
{{ 'mootools.js' | asset_url | script_tag }}
{{ 'slimbox.js' | asset_url | script_tag }}
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{{ 'slimbox.css' | asset_url | stylesheet_tag }}
{{ content_for_header }}
</head>
<body id="page-{{template}}">
<p class="hide"><a href="#navigation">Skip to navigation.</a></p>
<div id="wrapper">
<div class="content clearfix">
<div id="header">
<h2><a href="/">{{shop.name}}</a></h2>
</div>
<div id="left-col">
{{ content_for_layout }}
</div>
<div id="right-col">
{% if template != 'cart' %}
<div id="cart-right-col">
<dl id="cart-right-col-info">
<dt>Shopping Cart</dt>
<dd>
{% if cart.item_count != 0 %}
<a href="/cart">{{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }}</a> in your cart
{% else %}
Your cart is empty
{% endif %}
</dd>
</dl>
</div>
{% endif %}
<div id="search">
<dl id="searchbox">
<dt>Search</dt>
<dd>
<form action="/search" method="get">
<fieldset>
<input class="search-input" type="text" onclick="this.select()" value="Search this shop..." name="q" />
</fieldset>
</form>
</dd>
</dl>
</div>
<div id="navigation">
<dl class="navbar">
<dt>Navigation</dt>
{% for link in linklists.main-menu.links %}
<dd>{{ link.title | link_to: link.url }}</dd>
{% endfor %}
</dl>
{% if tags %}
<dl class="navbar">
<dt>Tags</dt>
{% for tag in collection.tags %}
<dd>{{ tag | highlight_active_tag | link_to_tag: tag }}</dd>
{% endfor %}
</dl>
{% endif %}
</div>
</div>
</div>
<div id="content-padding"></div>
</div>
<div id="footer">
{% for link in linklists.footer.links %}
{{ link.title | link_to: link.url }} {% if forloop.rindex != 1 %} | {% endif %}
{% endfor %}
</div>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<div id="page" class="innerpage clearfix">
<div id="text-page">
<div class="entry">
<h1>Oh no!</h1>
<div class="entry-post">
Seems like you are looking for something that just isn't here. <a href="/">Try heading back to our main page</a>. Or you can checkout some of our featured products below.
</div>
</div>
</div>
<h1>Featured Products</h1>
<ul class="item-list clearfix">
{% for product in collections.frontpage.products %}
<li>
<form action="/cart/add" method="post">
<div class="item-list-item">
<div class="ili-top clearfix">
<div class="ili-top-content">
<h2><a href="{{product.url}}">{{product.title}}</a></h2>
<p>{{ product.description | truncatewords: 15 }}</p>
</div>
<a href="{{product.url}}" class="ili-top-image"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}"/></a>
</div>
<div class="ili-bottom clearfix">
<p class="hiddenvariants" style="display: none">{% for variant in product.variants %}<span><input type="radio" name="id" value="{{variant.id}}" id="radio_{{variant.id}}" style="vertical-align: middle;" {%if forloop.first%} checked="checked" {%endif%} /><label for="radio_{{variant.id}}">{{ variant.price | money_with_currency }} - {{ variant.title }}</label></span>{% endfor %}</p>
<input type="submit" class="" value="Add to Basket" />
<p>
<a href="{{product.url}}">View Details</a>
<span>
{% if product.compare_at_price %}
{% if product.price_min != product.compare_at_price %}
{{product.compare_at_price | money}} -
{% endif %}
{% endif %}
<strong>
{{product.price_min | money}}
</strong>
</span>
</p>
</div>
</div>
</form>
</li>
{% endfor %}
</ul>
</div>
<!-- end page -->

View File

@@ -0,0 +1,98 @@
<div id="page" class="innerpage clearfix">
<div id="text-page">
<div class="entry">
<h1><span>{{article.title}}</span></h1>
<div class="entry-post">
<div class="meta">{{ article.created_at | date: "%b %d" }}</div>
{{ article.content }}
</div>
<!-- Comments -->
{% if blog.comments_enabled? %}
<div id="comments">
<h2>Comments</h2>
<!-- List all comments -->
<ul id="comment-list">
{% for comment in article.comments %}
<li>
<div class="comment">
{{ comment.content }}
</div>
<div class="comment-details">
Posted by <span class="comment-author">{{ comment.author }}</span> on <span class="comment-date">{{ comment.created_at | date: "%B %d, %Y" }}</span>
</div>
</li>
{% endfor %}
</ul>
<!-- Comment Form -->
<div id="comment-form">
{% form article %}
<h2>Leave a comment</h2>
<!-- Check if a comment has been submitted in the last request, and if yes display an appropriate message -->
{% if form.posted_successfully? %}
{% if blog.moderated? %}
<div class="notice">
Successfully posted your comment.<br />
It will have to be approved by the blog owner first before showing up.
</div>
{% else %}
<div class="notice">Successfully posted your comment.</div>
{% endif %}
{% endif %}
{% if form.errors %}
<div class="notice error">Not all the fields have been filled out correctly!</div>
{% endif %}
<dl>
<dt class="{% if form.errors contains 'author' %}error{% endif %}"><label for="comment_author">Your name</label></dt>
<dd><input type="text" id="comment_author" name="comment[author]" size="40" value="{{form.author}}" class="{% if form.errors contains 'author' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'email' %}error{% endif %}"><label for="comment_email">Your email</label></dt>
<dd><input type="text" id="comment_email" name="comment[email]" size="40" value="{{form.email}}" class="{% if form.errors contains 'email' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'body' %}error{% endif %}"><label for="comment_body">Your comment</label></dt>
<dd><textarea id="comment_body" name="comment[body]" cols="40" rows="5" class="{% if form.errors contains 'body' %}input-error{% endif %}">{{form.body}}</textarea></dd>
</dl>
{% if blog.moderated? %}
<p class="hint">comments have to be approved before showing up</p>
{% endif %}
<input type="submit" value="Post comment" id="comment-submit" />
{% endform %}
</div>
<!-- END Comment Form -->
</div>
{% endif %}
<!-- END Comments -->
</div>
</div>
<div id="three-reasons" class="clearfix">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bit encrypted.</p>
</li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,41 @@
<div id="page" class="innerpage clearfix">
<div id="text-page">
<h1>Post from our blog...</h1>
{% paginate blog.articles by 20 %}
{% for article in blog.articles %}
<div class="entry">
<h1><span><a href="{{ article.url }}">{{ article.title }}</a></span></h1>
<div class="entry-post">
<div class="meta">{{ article.created_at | date: "%b %d" }}</div>
{{ article.content }}
</div>
</div>
{% endfor %}
<div class="paginate clearfix">
{{ paginate | default_pagination }}
</div>
{% endpaginate %}
</div>
<div id="three-reasons" class="clearfix">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bit encrypted.</p>
</li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,134 @@
<script type="text/javascript">
function remove_item(id) {
document.getElementById('updates_'+id).value = 0;
document.getElementById('cart').submit();
}
</script>
<div id="page" class="innerpage clearfix">.
{% if cart.item_count == 0 %}
<h1>Your cart is currently empty.</h1>
{% else %}
<h1>Your Cart <span>({{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }}, {{cart.total_price | money_with_currency }} total)</span></h1>
<form action="/cart" method="post" id="cart-form">
<div id="cart-wrap">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col" class="td-image"><label>Image</label></th>
<th scope="col" class="td-title"><label>Product Title</label></th>
<th scope="col" class="td-count"><label>Count</label></th>
<th scope="col" class="td-price"><label>Cost</label></th>
<th scope="col" class="td-delete"><label>Remove</label></th>
</tr>
{% for item in cart.items %}
<tr class="{% cycle 'reg', 'alt' %}">
<td colspan="5">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="td-image"><a href="{{item.product.url}}">{{ item.product.featured_image | product_img_url: 'thumb' | img_tag }}</a></td>
<td class="td-title"><p>{{ item.title }}</p></td>
<td class="td-count"><label>Count:</label> <input type="text" class="quantity item-count" name="updates[{{item.variant.id}}]" id="updates_{{item.variant.id}}" value="{{item.quantity}}" onfocus="this.select();"/></td>
<td class="td-price">{{item.line_price | money }}</td>
<td class="td-delete"><a href="#" onclick="remove_item({{item.variant.id}}); return false;">Remove</a></td>
</tr>
</table>
</td>
</tr>
{% endfor %}
</table>
<div id="finish-up">
<div class="latest-news-box">
{{ pages.shopping-cart.content }}
</div>
<p class="order-total">
<span><strong>Order Total:</strong> {{cart.total_price | money_with_currency }}</span>
</p>
<p class="update-cart"><input type="submit" value="Refresh Cart" name="update" /></p>
<p class="go-checkout"><input type="submit" value="Proceed to Checkout" name="checkout" /></p>
{% if additional_checkout_buttons %}
<div class="additional-checkout-buttons">
<p>- or -</p>
{{ content_for_additional_checkout_buttons }}
</div>
{% endif %}
</div>
</div>
</form>
{% endif %}
<h1 class="other-products"><span>Other Products You Might Enjoy</span></h1>
<ul class="item-list clearfix">
{% for product in collections.frontpage.products limit:2 %}
<li>
<form action="/cart/add" method="post">
<div class="item-list-item">
<div class="ili-top clearfix">
<div class="ili-top-content">
<h2><a href="{{product.url}}">{{product.title}}</a></h2>
<p>{{ product.description | truncatewords: 15 }}</p>
</div>
<a href="{{product.url}}" class="ili-top-image"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}"/></a>
</div>
<div class="ili-bottom clearfix">
<p class="hiddenvariants" style="display: none">{% for variant in product.variants %}<span><input type="radio" name="id" value="{{variant.id}}" id="radio_{{variant.id}}" style="vertical-align: middle;" {%if forloop.first%} checked="checked" {%endif%} /><label for="radio_{{variant.id}}">{{ variant.price | money_with_currency }} - {{ variant.title }}</label></span>{% endfor %}</p>
<input type="submit" class="" value="Add to Basket" />
<p>
<a href="{{product.url}}">View Details</a>
<span>
{% if product.compare_at_price %}
{% if product.price_min != product.compare_at_price %}
{{product.compare_at_price | money}} -
{% endif %}
{% endif %}
<strong>
{{product.price_min | money}}
</strong>
</span>
</p>
</div>
</div>
</form>
</li>
{% endfor %}
</ul>
<div id="three-reasons" class="clearfix">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bit encrypted.</p>
</li>
</ul>
</div>
</div>
<!-- end page -->

View File

@@ -0,0 +1,70 @@
<div id="page" class="innerpage clearfix">
<h1>{{ collection.title }}</h1>
{% if collection.description.size > 0 %}
<div class="latest-news">{{ collection.description }}</div>
{% endif %}
{% paginate collection.products by 8 %}
<ul class="item-list clearfix">
{% for product in collection.products %}
<li>
<form action="/cart/add" method="post">
<div class="item-list-item">
<div class="ili-top clearfix">
<div class="ili-top-content">
<h2><a href="{{product.url}}">{{product.title}}</a></h2>
<p>{{ product.description | truncatewords: 15 }}</p>
</div>
<a href="{{product.url}}" class="ili-top-image"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}"/></a>
</div>
<div class="ili-bottom clearfix">
<p class="hiddenvariants" style="display: none">{% for variant in product.variants %}<span><input type="radio" name="id" value="{{variant.id}}" id="radio_{{variant.id}}" style="vertical-align: middle;" {%if forloop.first%} checked="checked" {%endif%} /><label for="radio_{{variant.id}}">{{ variant.price | money_with_currency }} - {{ variant.title }}</label></span>{% endfor %}</p>
<input type="submit" class="" value="Add to Basket" />
<p>
<a href="{{product.url}}">View Details</a>
<span>
{% if product.compare_at_price %}
{% if product.price_min != product.compare_at_price %}
{{product.compare_at_price | money}} -
{% endif %}
{% endif %}
<strong>
{{product.price_min | money}}
</strong>
</span>
</p>
</div>
</div>
</form>
</li>
{% endfor %}
</ul>
<div class="paginate clearfix">
{{ paginate | default_pagination }}
</div>
<div id="three-reasons" class="clearfix">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bit encrypted.</p>
</li>
</ul>
</div>
</div>
{% endpaginate %}

View File

@@ -0,0 +1,94 @@
<div id="gwrap">
<div id="gbox">
<h1>Three Great Reasons You Should Shop With Us...</h1>
<ul>
<li class="gbox1">
<h2>Free Shipping</h2>
<p>On all orders over $25</p>
</li>
<li class="gbox2">
<h2>Top Quality</h2>
<p>Hand made in our shop</p>
</li>
<li class="gbox3">
<h2>100% Guarantee</h2>
<p>Any time, any reason</p>
</li>
</ul>
</div>
</div>
<div id="page" class="clearfix">
<div class="latest-news">{{pages.alert.content}}</div>
<ul class="item-list clearfix">
{% for product in collections.frontpage.products %}
<li>
<form action="/cart/add" method="post">
<div class="item-list-item">
<div class="ili-top clearfix">
<div class="ili-top-content">
<h2><a href="{{product.url}}">{{product.title}}</a></h2>
{{ product.description | truncatewords: 15 }}</p> <!-- extra cloding <p> tag for truncation -->
</div>
<a href="{{product.url}}" class="ili-top-image"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}"/></a>
</div>
<div class="ili-bottom clearfix">
<p class="hiddenvariants" style="display: none">{% for variant in product.variants %}<span><input type="radio" name="id" value="{{variant.id}}" id="radio_{{variant.id}}" style="vertical-align: middle;" {%if forloop.first%} checked="checked" {%endif%} /><label for="radio_{{variant.id}}">{{ variant.price | money_with_currency }} - {{ variant.title }}</label></span>{% endfor %}</p>
<input type="submit" class="" value="Add to Basket" />
<p>
<a href="{{product.url}}">View Details</a>
<span>
{% if product.compare_at_price %}
{% if product.price_min != product.compare_at_price %}
{{product.compare_at_price | money}} -
{% endif %}
{% endif %}
<strong>
{{product.price_min | money}}
</strong>
</span>
</p>
</div>
</div>
</form>
</li>
{% endfor %}
</ul>
<div id="one-two">
<div id="two">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-b">
<h4>Save Energy</h4>
<p>We're green, all the way.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bits encrypted.</p>
</li>
</ul>
</div>
<div id="one">
<h3>Our Company</h3>
{{pages.about-us.content | truncatewords: 49}} <a href="/pages/about-us">read more</a></p>
</div>
</div>
</div>
<!-- end page -->

View File

@@ -0,0 +1,56 @@
<div id="page" class="innerpage clearfix">
<div id="text-page">
<div class="entry">
<h1>{{page.title}}</h1>
<div class="entry-post">
{{page.content}}
</div>
</div>
</div>
<h1>Featured Products</h1>
<ul class="item-list clearfix">
{% for product in collections.frontpage.products %}
<li>
<form action="/cart/add" method="post">
<div class="item-list-item">
<div class="ili-top clearfix">
<div class="ili-top-content">
<h2><a href="{{product.url}}">{{product.title}}</a></h2>
<p>{{ product.description | truncatewords: 15 }}</p>
</div>
<a href="{{product.url}}" class="ili-top-image"><img src="{{ product.featured_image | product_img_url: 'small' }}" alt="{{ product.title | escape }}"/></a>
</div>
<div class="ili-bottom clearfix">
<p class="hiddenvariants" style="display: none">{% for variant in product.variants %}<span><input type="radio" name="id" value="{{variant.id}}" id="radio_{{variant.id}}" style="vertical-align: middle;" {%if forloop.first%} checked="checked" {%endif%} /><label for="radio_{{variant.id}}">{{ variant.price | money_with_currency }} - {{ variant.title }}</label></span>{% endfor %}</p>
<input type="submit" class="" value="Add to Basket" />
<p>
<a href="{{product.url}}">View Details</a>
<span>
{% if product.compare_at_price %}
{% if product.price_min != product.compare_at_price %}
{{product.compare_at_price | money}} -
{% endif %}
{% endif %}
<strong>
{{product.price_min | money}}
</strong>
</span>
</p>
</div>
</div>
</form>
</li>
{% endfor %}
</ul>
</div>
<!-- end page -->

View File

@@ -0,0 +1,116 @@
<div id="page" class="innerpage clearfix">
<h1>{{ collection.title }} {{ product.title }}</h1>
<p class="latest-news"><strong>Product Tags: </strong>
{% for tag in product.tags %}
<a href="/collections/all/{{ tag }}">{{ tag }}</a> |
{% endfor %}
</p>
<div class="product clearfix">
<div class="product-info">
<h1>{{ product.title }}</h1>
<div class="product-info-description">
<p>{{ product.description }} </p>
</div>
{% if product.available %}
<form action="/cart/add" method="post">
<h2>Product Options:</h2>
<select id="product-info-options" name="id" class="product-info-options">
{% for variant in product.variants %}
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>
{% endfor %}
</select>
<div id="price-field"></div>
<div class="product-purchase-btn">
<input type="submit" class="add-this-to-cart" id="add-this-to-cart" value="Add to Basket" />
</div>
</form>
{% else %}
<h2>Sold out!</h2>
<p>Sorry, we're all out of this product. Check back often and order when it returns</p>
{% endif %}
</div>
<div class="product-images clearfix">
{% for image in product.images %}
{% if forloop.first %}
<div class="product-image-large">
<img src="{{ image | product_img_url: 'medium'}}" alt="{{product.title | escape }}" />
</div>
{% else %}
{% endif %}
{% endfor %}
<ul class="product-thumbs clearfix">
{% for image in product.images %}
{% if forloop.first %}
{% else %}
<li>
<a href="{{ image | product_img_url: 'large' }}" class="product-thumbs" rel="lightbox[product]" title="">
<img src="{{ image | product_img_url: 'small'}}" alt="{{product.title | escape }}" />
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<div id="three-reasons" class="clearfix">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bit encrypted.</p>
</li>
</ul>
</div>
</div>
<!-- end page -->
<script type="text/javascript">
<!--
// prototype callback for multi variants dropdown selector
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
$('add-this-to-cart').removeClassName('disabled'); // remove unavailable class from add-to-cart button
$('add-this-to-cart').disabled = false; // reenable add-to-cart button
$('price-field').innerHTML = Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}"); // update price field
} else {
// variant doesn't exist
$('add-this-to-cart').addClassName('disabled'); // set add-to-cart button to unavailable class
$('add-this-to-cart').disabled = true; // disable add-to-cart button
$('price-field').innerHTML = (variant) ? "Sold Out" : "Unavailable"; // update price-field message
}
};
// initialize multi selector for product
Event.observe(document, 'dom:loaded', function() {
new Shopify.OptionSelectors("product-info-options", { product: {{ product | json }}, onVariantSelected: selectCallback });
});
-->
</script>

View File

@@ -0,0 +1,51 @@
<div id="page" class="innerpage clearfix">
<h1>Search Results</h1>
{% if search.performed %}
{% paginate search.results by 10 %}
{% if search.results == empty %}
<div class="latest-news">Your search for "{{search.terms | escape}}" did not yield any results</div>
{% else %}
<ul class="search-list clearfix">
{% for item in search.results %}
<li>
<h3 class="stitle">{{ item.title | link_to: item.url }}</h3>
<p class="sinfo">{{ item.content | strip_html | truncatewords: 65 | highlight: search.terms }} ... <a href="{{item.url}}" title="">view this item</a></p>
</li>
{% endfor %}
</ul>
{% endif %}
<div class="paginate clearfix">
{{ paginate | default_pagination }}
</div>
<div id="three-reasons" class="clearfix">
<h3>Why Shop With Us?</h3>
<ul>
<li class="two-a">
<h4>24 Hours</h4>
<p>We're always here to help.</p>
</li>
<li class="two-c">
<h4>No Spam</h4>
<p>We'll never share your info.</p>
</li>
<li class="two-d">
<h4>Secure Servers</h4>
<p>Checkout is 256bit encrypted.</p>
</li>
</ul>
</div>
</div>
{% endpaginate %}
{% endif %}

View File

@@ -0,0 +1,90 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{shop.name}} - {{page_title}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
{{ 'reset.css' | asset_url | stylesheet_tag }}
{{ 'style.css' | asset_url | stylesheet_tag }}
{{ 'lightbox.css' | asset_url | stylesheet_tag }}
{{ 'prototype/1.6/prototype.js' | global_asset_url | script_tag }}
{{ 'scriptaculous/1.8.2/scriptaculous.js' | global_asset_url | script_tag }}
{{ 'lightbox.js' | asset_url | script_tag }}
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{{ content_for_header }}
</head>
<body id="page-{{template}}">
<div id="wrap">
<div id="top">
<div id="cart">
<h3>Shopping Cart</h3>
<p class="cart-count">
{% if cart.item_count == 0 %}
Your cart is currently empty
{% else %}
{{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} <span>-</span> Total: {{cart.total_price | money_with_currency }} <span>-</span> <a href="/cart">View Cart</a>
{% endif %}
</p>
</div>
<div id="site-title">
<h3><a href="/">{{shop.name}}</a></h3>
<h4><span>Tribble: A Shopify Theme</span></h4>
</div>
</div>
<ul id="nav">
{% for link in linklists.main-menu.links %}
<li>{{ link.title | link_to: link.url }}</li>
{% endfor %}
</ul>
{{ content_for_layout }}
<div id="foot" class="clearfix">
<div class="quick-links">
<h4>Quick Navigation</h4>
<ul class="clearfix">
<li><a href="/">Home</a></li>
<li><a href="#top">Back to top</a></li>
{% for link in linklists.main-menu.links %}
<li>{{ link.title | link_to: link.url }}</li>
{% endfor %}
</ul>
</div>
<div class="quick-contact">
<h4>Quick Contact</h4>
<div class="vcard">
<div class="org fn">
<div class="organization-name">Really Great Widget Co.</div>
</div>
<div class="adr">
<span class="street-address">2531 Barrington Court</span>
<span class="locality">Hayward</span>,
<abbr title="California" class="region">CA</abbr>
<span class="postal-code">94545</span>
</div>
<a class="email" href="mailto:email@myshopifysite.com">
email@myshopifysite.com
</a>
<div class="tel">
<span class="type">Support:</span> <span class="value">800-555-9954</span>
</div>
</div>
</div>
<p><a href="http://shopify.com" class="we-made">Powered by Shopify</a> &copy; Copyright {{ "now" | date: "%Y" }} {{ shop.name }}, All Rights Reserved. <a href="/blogs/news.xml" id="foot-rss">RSS Feed</a></p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,66 @@
<div class="article">
<h3 class="article-head-title">{{ article.title }}</h3>
<p> posted {{ article.created_at | date: "%Y %h" }} by {{ article.author }}</p>
<div class="article-body textile">
{{ article.content }}
</div>
</div>
{% if blog.comments_enabled? %}
<div id="comments">
<h3>Comments</h3>
<!-- List all comments -->
<ul>
{% for comment in article.comments %}
<li>
<div class="comment">
{{ comment.content }}
</div>
<div class="comment-details">
Posted by {{ comment.author }} on {{ comment.created_at | date: "%B %d, %Y" }}
</div>
</li>
{% endfor %}
</ul>
<!-- Comment Form -->
{% form article %}
<h3>Leave a comment</h3>
<!-- Check if a comment has been submitted in the last request, and if yes display an appropriate message -->
{% if form.posted_successfully? %}
{% if blog.moderated? %}
<div class="notice">
Successfully posted your comment.<br />
It will have to be approved by the blog owner first before showing up.
</div>
{% else %}
<div class="notice">Successfully posted your comment.</div>
{% endif %}
{% endif %}
{% if form.errors %}
<div class="notice error">Not all the fields have been filled out correctly!</div>
{% endif %}
<dl>
<dt class="{% if form.errors contains 'author' %}error{% endif %}"><label for="comment_author">Your name</label></dt>
<dd><input type="text" id="comment_author" name="comment[author]" size="40" value="{{form.author}}" class="{% if form.errors contains 'author' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'email' %}error{% endif %}"><label for="comment_email">Your email</label></dt>
<dd><input type="text" id="comment_email" name="comment[email]" size="40" value="{{form.email}}" class="{% if form.errors contains 'email' %}input-error{% endif %}" /></dd>
<dt class="{% if form.errors contains 'body' %}error{% endif %}"><label for="comment_body">Your comment</label></dt>
<dd><textarea id="comment_body" name="comment[body]" cols="40" rows="5" class="{% if form.errors contains 'body' %}input-error{% endif %}">{{form.body}}</textarea></dd>
</dl>
{% if blog.moderated? %}
<p class="hint">comments have to be approved before showing up</p>
{% endif %}
<input type="submit" value="Post comment" />
{% endform %}
</div>
{% endif %}

View File

@@ -0,0 +1,32 @@
<div id="shop-id-label_about">
<h3 class="article-head-title">{{page.title}}</h3>
{% paginate blog.articles by 20 %}
{% for article in blog.articles %}
<div class="article">
<h3 class="article-head-title">
<a href="{{article.url}}">{{ article.title }}</a>
</h3>
<p>
{% if blog.comments_enabled? %}
<a href="{{article.url}}#comments">{{ article.comments_count }} comments</a>
&mdash;
{% endif %}
posted {{ article.created_at | date: "%Y %h" }} by {{ article.author }}</p>
<div class="article-body textile">
{{ article.content }}
</div>
</div>
{% endfor %}
<div id="pagination">
{{ paginate | default_pagination }}
</div>
{% endpaginate %}
</div>
<div class="clear-me"></div>

View File

@@ -0,0 +1,58 @@
<h1>Shopping Cart</h1>
{% if cart.item_count == 0 %}
<p><strong>Your shopping basket is empty.</strong> Perhaps a featured item below is of interest...</p>
<table id="gallery">
{% tablerow product in collections.frontpage.products cols: 3 limit: 12 %}
<div class="gallery-image">
<a href="{{ product.url | within: collections.frontpage }}" title="{{ product.title | escape }} &mdash; {{ product.description | strip_html | truncate: 50 | escape }}"><img src="{{ product.images.first | product_img_url: 'medium' }}" alt="{{ product.title | escape }}" /></a>
</div>
<div class="gallery-info">
<a href="{{ product.url | within: collections.frontpage }}">{{ product.title | truncate: 30 }}</a><br />
<small>{{ product.price | money }}{% if product.compare_at_price_max > product.price %} <del>{{ product.compare_at_price_max | money }}</del>{% endif %}</small>
</div>
{% endtablerow %}
</table>
{% else %}
<script type="text/javascript">
function remove_item(id) {
document.getElementById('updates_'+id).value = 0;
document.getElementById('cartform').submit();
}
</script>
<form action="/cart" method="post" id="cartform">
<table id="basket">
<tr>
<th>Item Description</th>
<th>Price</th>
<th>Qty</th>
<th>Delete</th>
<th>Total</th>
</tr>{% for item in cart.items %}
<tr class="basket-{% cycle 'odd', 'even' %}">
<td class="basket-column-one">
<div class="basket-images">
<a href="{{ item.product.url }}" title="{{ item.title | escape }} &mdash; {{ item.product.description | strip_html | truncate: 50 | escape }}"><img src="{{ item.product.images.first | product_img_url: 'thumb' }}" alt="{{ item.title | escape }}" /></a>
</div>
<div class="basket-desc">
<p><a href="{{ item.product.url }}">{{ item.title }}</a></p>
{{ item.product.description | strip_html | truncate: 120 }}
</div>
</td>
<td class="basket-column">{{ item.price | money }}{% if item.variant.compare_at_price > item.price %}<br /><del>{{ item.variant.compare_at_price | money }}</del>{% endif %}</td>
<td class="basket-column"><input type="text" size="4" name="updates[{{item.variant.id}}]" id="updates_{{ item.variant.id }}" value="{{ item.quantity }}" onfocus="this.select();"/></td>
<td class="basket-column"><a href="#" onclick="remove_item({{ item.variant.id }}); return false;">Remove</a></td>
<td class="basket-column">{{ item.line_price | money }}</td>
</tr>{% endfor %}
</table>
<div id="basket-right">
<h3>Subtotal {{ cart.total_price | money }}</h3>
<input type="image" src="{{ 'update.png' | asset_url }}" id="update-cart" name="update" value="Update" />
<input type="image" src="{{ 'checkout.png' | asset_url }}" name="checkout" value="Checkout" />
{% if additional_checkout_buttons %}
<div class="additional-checkout-buttons">
<p>- or -</p>
{{ content_for_additional_checkout_buttons }}
</div>
{% endif %}
</div>
</form>{% endif %}

View File

@@ -0,0 +1,19 @@
{% paginate collection.products by 12 %}{% if collection.products.size == 0 %}
<strong>No products found in this collection.</strong>{% else %}
<h1>{{ collection.title }}</h1>
{{ collection.description }}
<table id="gallery">
{% tablerow product in collection.products cols: 3 %}
<div class="gallery-image">
<a href="{{ product.url | within: collection }}" title="{{ product.title | escape }} &mdash; {{ product.description | strip_html | truncate: 50 | escape }}"><img src="{{ product.images.first | product_img_url: 'small' }}" alt="{{ product.title | escape }}" /></a>
</div>
<div class="gallery-info">
<a href="{{ product.url | within: collection }}">{{ product.title | truncate: 30 }}</a><br />
<small>{{ product.price | money }}{% if product.compare_at_price_max > product.price %} <del>{{ product.compare_at_price_max | money }}</del>{% endif %}</small>
</div>
{% endtablerow %}
</table>{% if paginate.pages > 1 %}
<div id="paginate">
{{ paginate | default_pagination }}
</div>{% endif %}{% endif %}
{% endpaginate %}

View File

@@ -0,0 +1,22 @@
<div id="about-excerpt">
{% assign article = pages.frontpage %}
{% if article.content != "" %}
<h2>{{ article.title }}</h2>
{{ article.content }}
{% else %}
In <em>Admin &gt; Blogs &amp; Pages</em>, create a page with the handle <strong><code>frontpage</code></strong> and it will show up here.<br />
{{ "Learn more about handles" | link_to "http://wiki.shopify.com/Handle" }}
{% endif %}
</div>
<table id="gallery">
{% tablerow product in collections.frontpage.products cols: 3 limit: 12 %}
<div class="gallery-image">
<a href="{{ product.url | within: collections.frontpage }}" title="{{ product.title | escape }} &mdash; {{ product.description | strip_html | truncate: 50 | escape }}"><img src="{{ product.images.first | product_img_url: 'small' }}" alt="{{ product.title | escape }}" /></a>
</div>
<div class="gallery-info">
<a href="{{ product.url | within: collections.frontpage }}">{{ product.title | truncate: 30 }}</a><br />
<small>{{ product.price | money }}{% if product.compare_at_price_max > product.price %} <del>{{ product.compare_at_price_max | money }}</del>{% endif %}</small>
</div>
{% endtablerow %}
</table>

View File

@@ -0,0 +1,3 @@
<h1>{{ page.title }}</h1>
{{ page.content }}

View File

@@ -0,0 +1,62 @@
<div id="product-left">
{% for image in product.images %}{% if forloop.first %}<div id="product-image">
<a href="{{ image | product_img_url: 'large' }}" rel="lightbox[images]" title="{{ product.title | escape }}"><img src="{{ image | product_img_url: 'medium' }}" alt="{{ product.title | escape }}" /></a>
</div>{% else %}
<div class="product-images">
<a href="{{ image | product_img_url: 'large' }}" rel="lightbox[images]" title="{{ product.title | escape }}"><img src="{{ image | product_img_url: 'small' }}" alt="{{ product.title | escape }}" /></a>
</div>{% endif %}{% endfor %}
</div>
<div id="product-right">
<h1>{{ product.title }}</h1>
{{ product.description }}
{% if product.available %}
<form action="/cart/add" method="post">
<div id="product-variants">
<div id="price-field"></div>
<select id="product-select" name='id'>
{% for variant in product.variants %}
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>
{% endfor %}
</select>
</div>
<input type="image" src="{{ 'purchase.png' | asset_url }}" name="add" value="Purchase" id="purchase" />
</form>
{% else %}
<p class="bold-red">This product is temporarily unavailable</p>
{% endif %}
<div id="product-details">
<strong>Continue Shopping</strong><br />
Browse more {{ product.type | link_to_type }} or additional {{ product.vendor | link_to_vendor }} products.
</div>
</div>
<script type="text/javascript">
<!--
// mootools callback for multi variants dropdown selector
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
$('purchase').removeClass('disabled'); // remove unavailable class from add-to-cart button
$('purchase').disabled = false; // reenable add-to-cart button
$('price-field').innerHTML = Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}"); // update price field
} else {
// variant doesn't exist
$('purchase').addClass('disabled'); // set add-to-cart button to unavailable class
$('purchase').disabled = true; // disable add-to-cart button
$('price-field').innerHTML = (variant) ? "Sold Out" : "Unavailable"; // update price-field message
}
};
// initialize multi selector for product
window.addEvent('domready', function() {
new Shopify.OptionSelectors("product-select", { product: {{ product | json }}, onVariantSelected: selectCallback });
});
-->
</script>

View File

@@ -0,0 +1,122 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{ shop.name }} &mdash; {{ page_title }}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{{ 'stylesheet.css' | asset_url | stylesheet_tag }}
<!-- Additional colour schemes for this theme. If you want to use them, just replace the above line with one of these
{{ 'caramel.css' | asset_url | stylesheet_tag }}
{{ 'sea.css' | asset_url | stylesheet_tag }}
-->
{{ 'mootools.js' | global_asset_url | script_tag }}
{{ 'slimbox.js' | global_asset_url | script_tag }}
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{{ content_for_header }}
</head>
<body id="page-{{ template }}">
<div id="header">
<div class="container">
<div id="logo">
<h1><a href="/" title="{{ shop.name }}">{{ shop.name }}</a></h1>
</div>
<div id="navigation">
<ul id="navigate">
<li><a href="/cart">View Cart</a></li>
{% for link in linklists.main-menu.links reversed %}
<li><a href="{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
</div>
<div id="mini-header">
<div class="container">
<div id="shopping-cart">
<a href="/cart">Your shopping cart contains {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }}</a>
</div>
<div id="search-box">
<form action="/search" method="get">
<input type="text" name="q" id="q" />
<input type="image" src="{{ 'seek.png' | asset_url }}" value="Seek" onclick="this.parentNode.submit(); return false;" id="seek" />
</form>
</div>
</div>
</div>
<div id="layout">
<div class="container">
<div id="layout-left" {% if template != "cart" %}{% if template != "product" %}style="width:619px"{% endif %}{% endif %}>{% if template == "search" %}
<h1>Search Results</h1>{% endif %}
{{ content_for_layout }}
</div>{% if template != "cart" %}{% if template != "product" %}
<div id="layout-right">
{% if template == "index" %}
{% if blogs.news.articles.size > 1 %}
<a href="{{ shop.url }}/blogs/news.xml"><img src="{{ 'feed.png' | asset_url }}" alt="Subscribe" class="feed" /></a>
<h3><a href="/blogs/news">More news</a></h3>
<ul id="blogs">{% for article in blogs.news.articles limit: 6 offset: 1 %}
<li><a href="{{ article.url }}">{{ article.title | strip_html | truncate: 30 }}</a><br />
<small>{{ article.content | strip_html | truncatewords: 12 }}</small>
</li>{% endfor %}
</ul>
{% endif %}
{% endif %}
{% if template == "collection" %}
<h3>Collection Tags</h3>
<div id="tags">{% if collection.tags.size == 0 %}
No tags found.{% else %}
<span class="tags">{% for tag in collection.tags %}{% if current_tags contains tag %} {{ tag | highlight_active_tag | link_to_remove_tag: tag }}{% else %} {{ tag | highlight_active_tag | link_to_add_tag: tag }}{% endif %}{% unless forloop.last %}, {% endunless %}{% endfor %}</span>{% endif %}
</div>
{% endif %}
<h3>Navigation</h3>
<ul id="links">
{% for link in linklists.main-menu.links %}
<li><a href="{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
</ul>
{% if template != "page" %}
<h3>Featured Products</h3>
<ul id="featuring">{% for product in collections.frontpage.products limit: 6 %}
<li class="featuring-list">
<div class="featuring-image">
<a href="{{ product.url | within: collections.frontpage }}" title="{{ product.title | escape }} &mdash; {{ product.description | strip_html | truncate: 50 }}"><img src="{{ product.images.first | product_img_url: 'icon' }}" alt="{{ product.title | escape }}" /></a>
</div>
<div class="featuring-info">
<a href="{{ product.url | within: collections.frontpage }}">{{ product.title | strip_html | truncate: 28 }}</a><br />
<small><span class="light">from</span> {{ product.price | money }}</small>
</div>
</li>{% endfor %}
</ul>
{% endif %}
</div>{% endif %}{% endif %}
</div>
</div>
<div id="footer">
<div id="footer-fader">
<div class="container">
<div id="footer-right">{% for link in linklists.footer.links %}
{{ link.title | link_to: link.url }} {% unless forloop.last %}&#124;{% endunless %}{% endfor %}
</div>
<span id="footer-left">
Copyright &copy; {{ "now" | date: "%Y" }} <a href="/">{{ shop.name }}</a>. All Rights Reserved. All prices {{ shop.currency }}.<br />
This website is powered by <a href="http://www.shopify.com">Shopify</a>.
</span>
</div>
</div>
</div>
</body>
</html>

View File

@@ -156,7 +156,9 @@ class ContextTest < Test::Unit::TestCase
assert_equal 'hi? hi!', context.invoke(:hi, 'hi?')
context = Context.new(@template)
assert_equal 'hi?', context.invoke(:hi, 'hi?')
assert_raises(FilterNotFound) {
context.invoke(:hi, 'hi?')
}
context.add_filters(filter)
assert_equal 'hi? hi!', context.invoke(:hi, 'hi?')
@@ -190,9 +192,10 @@ class ContextTest < Test::Unit::TestCase
end
context = Context.new(@template)
methods = context.strainer.methods
methods_before = context.strainer.methods.map { |method| method.to_s }
context.add_filters(filter)
assert_equal (methods + ['hi']).sort, context.strainer.methods.sort
methods_after = context.strainer.methods.map { |method| method.to_s }
assert_equal (methods_before + ["hi"]).sort, methods_after.sort
end
def test_add_item_in_outer_scope
@@ -289,11 +292,9 @@ class ContextTest < Test::Unit::TestCase
end
def test_access_hashes_with_hash_notation
@context['products'] = {'count' => 5, 'tags' => ['deepsnow', 'freestyle'] }
@context['product'] = {'variants' => [ {'title' => 'draft151cm'}, {'title' => 'element151cm'} ]}
assert_equal 5, @context['products["count"]']
assert_equal 'deepsnow', @context['products["tags"][0]']
assert_equal 'deepsnow', @context['products["tags"].first']
@@ -417,25 +418,25 @@ class ContextTest < Test::Unit::TestCase
end
def test_lambda_as_variable
@context['dynamic'] = lambda { 'Hello' }
@context['dynamic'] = proc { 'Hello' }
assert_equal 'Hello', @context['dynamic']
end
def test_nested_lambda_as_variable
@context['dynamic'] = { "lambda" => lambda { 'Hello' } }
@context['dynamic'] = { "lambda" => proc { 'Hello' } }
assert_equal 'Hello', @context['dynamic.lambda']
end
def test_array_containing_lambda_as_variable
@context['dynamic'] = [1,2, lambda { 'Hello' } ,4,5]
@context['dynamic'] = [1,2, proc { 'Hello' } ,4,5]
assert_equal 'Hello', @context['dynamic[2]']
end
def test_lambda_is_called_once
@context['callcount'] = lambda { @global ||= 0; @global += 1; @global.to_s }
@context['callcount'] = proc { @global ||= 0; @global += 1; @global.to_s }
assert_equal '1', @context['callcount']
assert_equal '1', @context['callcount']
@@ -445,7 +446,7 @@ class ContextTest < Test::Unit::TestCase
end
def test_nested_lambda_is_called_once
@context['callcount'] = { "lambda" => lambda { @global ||= 0; @global += 1; @global.to_s } }
@context['callcount'] = { "lambda" => proc { @global ||= 0; @global += 1; @global.to_s } }
assert_equal '1', @context['callcount.lambda']
assert_equal '1', @context['callcount.lambda']
@@ -455,7 +456,7 @@ class ContextTest < Test::Unit::TestCase
end
def test_lambda_in_array_is_called_once
@context['callcount'] = [1,2, lambda { @global ||= 0; @global += 1; @global.to_s } ,4,5]
@context['callcount'] = [1,2, proc { @global ||= 0; @global += 1; @global.to_s } ,4,5]
assert_equal '1', @context['callcount[2]']
assert_equal '1', @context['callcount[2]']
@@ -467,7 +468,7 @@ class ContextTest < Test::Unit::TestCase
def test_access_to_context_from_proc
@context.registers[:magic] = 345392
@context['magic'] = lambda { @context.registers[:magic] }
@context['magic'] = proc { @context.registers[:magic] }
assert_equal 345392, @context['magic']
end

View File

@@ -11,14 +11,14 @@ class SecurityTest < Test::Unit::TestCase
def test_no_instance_eval
text = %( {{ '1+1' | instance_eval }} )
expected = %| 1+1 |
expected = %! Liquid error: Error - filter 'instance_eval' in ''1+1' | instance_eval' could not be found. !
assert_equal expected, Template.parse(text).render(@assigns)
end
def test_no_existing_instance_eval
text = %( {{ '1+1' | __instance_eval__ }} )
expected = %| 1+1 |
expected = %! Liquid error: Error - filter '__instance_eval__' in ''1+1' | __instance_eval__' could not be found. !
assert_equal expected, Template.parse(text).render(@assigns)
end
@@ -26,7 +26,7 @@ class SecurityTest < Test::Unit::TestCase
def test_no_instance_eval_after_mixing_in_new_filter
text = %( {{ '1+1' | instance_eval }} )
expected = %| 1+1 |
expected = %! Liquid error: Error - filter 'instance_eval' in ''1+1' | instance_eval' could not be found. !
assert_equal expected, Template.parse(text).render(@assigns)
end
@@ -34,7 +34,7 @@ class SecurityTest < Test::Unit::TestCase
def test_no_instance_eval_later_in_chain
text = %( {{ '1+1' | add_one | instance_eval }} )
expected = %| 1+1 + 1 |
expected = %! Liquid error: Error - filter 'instance_eval' in ''1+1' | add_one | instance_eval' could not be found. !
assert_equal expected, Template.parse(text).render(@assigns, :filters => SecurityFilter)
end

View File

@@ -3,14 +3,14 @@ require File.dirname(__FILE__) + '/helper'
class StandardTagTest < Test::Unit::TestCase
include Liquid
def test_tag
def test_tag
tag = Tag.new('tag', [], [])
assert_equal 'liquid::tag', tag.name
assert_equal '', tag.render(Context.new)
assert_equal 'liquid::tag', tag.name
assert_equal '', tag.render(Context.new)
end
def test_no_transform
assert_template_result('this text should come out of the template without change...',
'this text should come out of the template without change...')
@@ -18,60 +18,60 @@ class StandardTagTest < Test::Unit::TestCase
assert_template_result('<blah>','<blah>')
assert_template_result('|,.:','|,.:')
assert_template_result('','')
text = %|this shouldnt see any transformation either but has multiple lines
as you can clearly see here ...|
assert_template_result(text,text)
end
def test_has_a_block_which_does_nothing
assert_template_result(%|the comment block should be removed .. right?|,
%|the comment block should be removed {%comment%} be gone.. {%endcomment%} .. right?|)
assert_template_result('','{%comment%}{%endcomment%}')
assert_template_result('','{%comment%}{% endcomment %}')
assert_template_result('','{% comment %}{%endcomment%}')
assert_template_result('','{% comment %}{% endcomment %}')
assert_template_result('','{%comment%}comment{%endcomment%}')
assert_template_result('','{% comment %}comment{% endcomment %}')
assert_template_result('foobar','foo{%comment%}comment{%endcomment%}bar')
assert_template_result('foobar','foo{% comment %}comment{% endcomment %}bar')
assert_template_result('foobar','foo{%comment%} comment {%endcomment%}bar')
assert_template_result('foobar','foo{% comment %} comment {% endcomment %}bar')
assert_template_result('foo bar','foo {%comment%} {%endcomment%} bar')
assert_template_result('foo bar','foo {%comment%}comment{%endcomment%} bar')
assert_template_result('foo bar','foo {%comment%} comment {%endcomment%} bar')
assert_template_result('foobar','foo{%comment%}
{%endcomment%}bar')
end
def test_for
assert_template_result(' yo yo yo yo ','{%for item in array%} yo {%endfor%}','array' => [1,2,3,4])
assert_template_result('yoyo','{%for item in array%}yo{%endfor%}','array' => [1,2])
assert_template_result(' yo ','{%for item in array%} yo {%endfor%}','array' => [1])
assert_template_result('','{%for item in array%}{%endfor%}','array' => [1,2])
expected = <<HERE
yo
yo
yo
HERE
template = <<HERE
{%for item in array%}
{%for item in array%}
yo
{%endfor%}
{%endfor%}
HERE
assert_template_result(expected,template,'array' => [1,2,3])
end
def test_for_with_range
assert_template_result(' 1 2 3 ','{%for item in (1..3) %} {{item}} {%endfor%}')
assert_template_result(' 1 2 3 ','{%for item in (1..3) %} {{item}} {%endfor%}')
end
def test_for_with_variable
@@ -82,7 +82,7 @@ HERE
assert_template_result('a b c','{%for item in array%}{{item}}{%endfor%}','array' => ['a',' ','b',' ','c'])
assert_template_result('abc','{%for item in array%}{{item}}{%endfor%}','array' => ['a','','b','','c'])
end
def test_for_helpers
assigns = {'array' => [1,2,3] }
assert_template_result(' 1/3 2/3 3/3 ','{%for item in array%} {{forloop.index}}/{{forloop.length}} {%endfor%}',assigns)
@@ -93,37 +93,37 @@ HERE
assert_template_result(' true false false ','{%for item in array%} {{forloop.first}} {%endfor%}',assigns)
assert_template_result(' false false true ','{%for item in array%} {{forloop.last}} {%endfor%}',assigns)
end
def test_for_and_if
assigns = {'array' => [1,2,3] }
assert_template_result('+--', '{%for item in array%}{% if forloop.first %}+{% else %}-{% endif %}{%endfor%}', assigns)
end
def test_limiting
assigns = {'array' => [1,2,3,4,5,6,7,8,9,0]}
assert_template_result('12','{%for i in array limit:2 %}{{ i }}{%endfor%}',assigns)
assert_template_result('1234','{%for i in array limit:4 %}{{ i }}{%endfor%}',assigns)
assert_template_result('3456','{%for i in array limit:4 offset:2 %}{{ i }}{%endfor%}',assigns)
assert_template_result('3456','{%for i in array limit: 4 offset: 2 %}{{ i }}{%endfor%}',assigns)
assert_template_result('3456','{%for i in array limit: 4 offset: 2 %}{{ i }}{%endfor%}',assigns)
end
def test_dynamic_variable_limiting
assigns = {'array' => [1,2,3,4,5,6,7,8,9,0]}
assigns['limit'] = 2
assigns['offset'] = 2
assert_template_result('34','{%for i in array limit: limit offset: offset %}{{ i }}{%endfor%}',assigns)
assert_template_result('34','{%for i in array limit: limit offset: offset %}{{ i }}{%endfor%}',assigns)
end
def test_nested_for
assigns = {'array' => [[1,2],[3,4],[5,6]] }
assert_template_result('123456','{%for item in array%}{%for i in item%}{{ i }}{%endfor%}{%endfor%}',assigns)
end
def test_offset_only
assigns = {'array' => [1,2,3,4,5,6,7,8,9,0]}
assert_template_result('890','{%for i in array offset:7 %}{{ i }}{%endfor%}',assigns)
end
def test_pause_resume
assigns = {'array' => {'items' => [1,2,3,4,5,6,7,8,9,0]}}
markup = <<-MKUP
@@ -142,7 +142,7 @@ HERE
XPCTD
assert_template_result(expected,markup,assigns)
end
def test_pause_resume_limit
assigns = {'array' => {'items' => [1,2,3,4,5,6,7,8,9,0]}}
markup = <<-MKUP
@@ -161,7 +161,7 @@ HERE
XPCTD
assert_template_result(expected,markup,assigns)
end
def test_pause_resume_BIG_limit
assigns = {'array' => {'items' => [1,2,3,4,5,6,7,8,9,0]}}
markup = <<-MKUP
@@ -180,8 +180,8 @@ HERE
XPCTD
assert_template_result(expected,markup,assigns)
end
def test_pause_resume_BIG_offset
assigns = {'array' => {'items' => [1,2,3,4,5,6,7,8,9,0]}}
markup = %q({%for i in array.items limit:3 %}{{i}}{%endfor%}
@@ -196,19 +196,19 @@ HERE
)
assert_template_result(expected,markup,assigns)
end
def test_assign
assigns = {'var' => 'content' }
assert_template_result('var2: var2:content','var2:{{var2}} {%assign var2 = var%} var2:{{var2}}',assigns)
end
def test_hyphenated_assign
assigns = {'a-b' => '1' }
assert_template_result('a-b:1 a-b:2','a-b:{{a-b}} {%assign a-b = 2 %}a-b:{{a-b}}',assigns)
end
def test_assign_with_colon_and_spaces
assigns = {'var' => {'a:b c' => {'paged' => '1' }}}
assert_template_result('var2: 1','{%assign var2 = var["a:b c"].paged %}var2: {{var2}}',assigns)
@@ -226,62 +226,62 @@ HERE
end
def test_case
assigns = {'condition' => 2 }
assigns = {'condition' => 2 }
assert_template_result(' its 2 ','{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', assigns)
assigns = {'condition' => 1 }
assert_template_result(' its 1 ','{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', assigns)
assigns = {'condition' => 3 }
assert_template_result('','{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', assigns)
assert_template_result('','{% case condition %}{% when 1 %} its 1 {% when 2 %} its 2 {% endcase %}', assigns)
assigns = {'condition' => "string here" }
assert_template_result(' hit ','{% case condition %}{% when "string here" %} hit {% endcase %}', assigns)
assert_template_result(' hit ','{% case condition %}{% when "string here" %} hit {% endcase %}', assigns)
assigns = {'condition' => "bad string here" }
assert_template_result('','{% case condition %}{% when "string here" %} hit {% endcase %}', assigns)
assert_template_result('','{% case condition %}{% when "string here" %} hit {% endcase %}', assigns)
end
def test_case_with_else
assigns = {'condition' => 5 }
assert_template_result(' hit ','{% case condition %}{% when 5 %} hit {% else %} else {% endcase %}', assigns)
assert_template_result(' hit ','{% case condition %}{% when 5 %} hit {% else %} else {% endcase %}', assigns)
assigns = {'condition' => 6 }
assert_template_result(' else ','{% case condition %}{% when 5 %} hit {% else %} else {% endcase %}', assigns)
assert_template_result(' else ','{% case condition %}{% when 5 %} hit {% else %} else {% endcase %}', assigns)
assigns = {'condition' => 6 }
assert_template_result(' else ','{% case condition %} {% when 5 %} hit {% else %} else {% endcase %}', assigns)
assert_template_result(' else ','{% case condition %} {% when 5 %} hit {% else %} else {% endcase %}', assigns)
end
def test_case_on_size
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [])
assert_template_result('1' , '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1])
assert_template_result('2' , '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1])
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1])
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1, 1])
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1, 1, 1])
end
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [])
assert_template_result('1' , '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1])
assert_template_result('2' , '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1])
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1])
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1, 1])
assert_template_result('', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% endcase %}', 'a' => [1, 1, 1, 1, 1])
end
def test_case_on_size_with_else
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [])
assert_template_result('1', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1])
assert_template_result('2', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1, 1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1, 1, 1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [])
assert_template_result('1', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1])
assert_template_result('2', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1, 1, 1])
assert_template_result('else', '{% case a.size %}{% when 1 %}1{% when 2 %}2{% else %}else{% endcase %}', 'a' => [1, 1, 1, 1, 1])
end
def test_case_on_length_with_else
assert_template_result('else', '{% case a.empty? %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('false', '{% case false %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('true', '{% case true %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('else', '{% case NULL %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('else', '{% case a.empty? %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('false', '{% case false %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('true', '{% case true %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
assert_template_result('else', '{% case NULL %}{% when true %}true{% when false %}false{% else %}else{% endcase %}', {})
end
def test_assign_from_case
def test_assign_from_case
# Example from the shopify forums
code = %q({% case collection.handle %}{% when 'menswear-jackets' %}{% assign ptitle = 'menswear' %}{% when 'menswear-t-shirts' %}{% assign ptitle = 'menswear' %}{% else %}{% assign ptitle = 'womenswear' %}{% endcase %}{{ ptitle }})
template = Liquid::Template.parse(code)
@@ -299,12 +299,12 @@ HERE
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => 3 })
assert_template_result(' its 4 ', code, {'condition' => 4 })
assert_template_result('', code, {'condition' => 5 })
code = '{% case condition %}{% when 1 or "string" or null %} its 1 or 2 or 3 {% when 4 %} its 4 {% endcase %}'
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => 1 })
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => 'string' })
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => nil })
assert_template_result('', code, {'condition' => 'something else' })
assert_template_result('', code, {'condition' => 'something else' })
end
def test_case_when_comma
@@ -314,87 +314,82 @@ HERE
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => 3 })
assert_template_result(' its 4 ', code, {'condition' => 4 })
assert_template_result('', code, {'condition' => 5 })
code = '{% case condition %}{% when 1, "string", null %} its 1 or 2 or 3 {% when 4 %} its 4 {% endcase %}'
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => 1 })
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => 'string' })
assert_template_result(' its 1 or 2 or 3 ', code, {'condition' => nil })
assert_template_result('', code, {'condition' => 'something else' })
assert_template_result('', code, {'condition' => 'something else' })
end
def test_assign
assert_equal 'variable', Liquid::Template.parse( '{% assign a = "variable"%}{{a}}' ).render
assert_equal 'variable', Liquid::Template.parse( '{% assign a = "variable"%}{{a}}' ).render
end
def test_assign_is_global
assert_equal 'variable', Liquid::Template.parse( '{%for i in (1..2) %}{% assign a = "variable"%}{% endfor %}{{a}}' ).render
end
assert_equal 'variable', Liquid::Template.parse( '{%for i in (1..2) %}{% assign a = "variable"%}{% endfor %}{{a}}' ).render
end
def test_case_detects_bad_syntax
assert_raise(SyntaxError) do
assert_template_result('', '{% case false %}{% when %}true{% endcase %}', {})
assert_template_result('', '{% case false %}{% when %}true{% endcase %}', {})
end
assert_raise(SyntaxError) do
assert_template_result('', '{% case false %}{% huh %}true{% endcase %}', {})
assert_template_result('', '{% case false %}{% huh %}true{% endcase %}', {})
end
end
def test_cycle
assert_template_result('one','{%cycle "one", "two"%}')
assert_template_result('one two','{%cycle "one", "two"%} {%cycle "one", "two"%}')
assert_template_result('one two one','{%cycle "one", "two"%} {%cycle "one", "two"%} {%cycle "one", "two"%}')
assert_template_result('text-align: left,text-align: right','{%cycle "text-align: left", "text-align: right" %},{%cycle "text-align: left", "text-align: right"%}')
assert_template_result('one','{%cycle "one", "two"%}')
assert_template_result('one two','{%cycle "one", "two"%} {%cycle "one", "two"%}')
assert_template_result('one two one','{%cycle "one", "two"%} {%cycle "one", "two"%} {%cycle "one", "two"%}')
assert_template_result('text-align: left text-align: right','{%cycle "text-align: left", "text-align: right" %} {%cycle "text-align: left", "text-align: right"%}')
assert_template_result('','.{% cycle '' %}')
assert_template_result('','.{% cycle "" %}')
assert_template_result('','.{% cycle "", "" %}')
assert_template_result('.','.{% cycle "", "", "</tr><tr>" %}')
assert_template_result('...</tr><tr> ','.{% cycle "", "", "</tr><tr>" %}.{% cycle "", "", "</tr><tr>" %}.{% cycle "", "", "</tr><tr>" %} {% cycle "", "", "</tr><tr>" %}')
end
def test_multiple_cycles
assert_template_result('1 2 1 1 2 3 1','{%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%}')
assert_template_result('1 2 1 1 2 3 1','{%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%}')
end
def test_multiple_named_cycles
assert_template_result('one one two two one one','{%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %} {%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %} {%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %}')
assert_template_result('one one two two one one','{%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %} {%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %} {%cycle 1: "one", "two" %} {%cycle 2: "one", "two" %}')
end
def test_multiple_named_cycles_with_names_from_context
assigns = {"var1" => 1, "var2" => 2 }
assert_template_result('one one two two one one','{%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %} {%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %} {%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %}', assigns)
assert_template_result('one one two two one one','{%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %} {%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %} {%cycle var1: "one", "two" %} {%cycle var2: "one", "two" %}', assigns)
end
def test_size_of_array
assigns = {"array" => [1,2,3,4]}
assert_template_result('array has 4 elements', "array has {{ array.size }} elements", assigns)
assert_template_result('array has 4 elements', "array has {{ array.size }} elements", assigns)
end
def test_size_of_hash
assigns = {"hash" => {:a => 1, :b => 2, :c=> 3, :d => 4}}
assert_template_result('hash has 4 elements', "hash has {{ hash.size }} elements", assigns)
end
def test_illegal_symbols
assert_template_result('', '{% if true == empty %}?{% endif %}', {})
assert_template_result('', '{% if true == null %}?{% endif %}', {})
assert_template_result('', '{% if empty == true %}?{% endif %}', {})
assert_template_result('', '{% if null == true %}?{% endif %}', {})
end
def test_for_reversed
assigns = {'array' => [ 1, 2, 3] }
assert_template_result('321','{%for item in array reversed %}{{item}}{%endfor%}',assigns)
assert_template_result('hash has 4 elements', "hash has {{ hash.size }} elements", assigns)
end
def test_illegal_symbols
assert_template_result('', '{% if true == empty %}?{% endif %}', {})
assert_template_result('', '{% if true == null %}?{% endif %}', {})
assert_template_result('', '{% if empty == true %}?{% endif %}', {})
assert_template_result('', '{% if null == true %}?{% endif %}', {})
end
def test_for_reversed
assigns = {'array' => [ 1, 2, 3] }
assert_template_result('321','{%for item in array reversed %}{{item}}{%endfor%}',assigns)
end
def test_ifchanged
assigns = {'array' => [ 1, 1, 2, 2, 3, 3] }
assert_template_result('123','{%for item in array%}{%ifchanged%}{{item}}{% endifchanged %}{%endfor%}',assigns)

View File

@@ -131,5 +131,42 @@ class VariableResolutionTest < Test::Unit::TestCase
template = Template.parse(%|{{ test.test }}|)
assert_equal 'worked', template.render('test' => {'test' => 'worked'})
end
def test_preset_assigns
template = Template.parse(%|{{ test }}|)
template.assigns['test'] = 'worked'
assert_equal 'worked', template.render
end
def test_reuse_parsed_template
template = Template.parse(%|{{ greeting }} {{ name }}|)
template.assigns['greeting'] = 'Goodbye'
assert_equal 'Hello Tobi', template.render('greeting' => 'Hello', 'name' => 'Tobi')
assert_equal 'Hello ', template.render('greeting' => 'Hello', 'unknown' => 'Tobi')
assert_equal 'Hello Brian', template.render('greeting' => 'Hello', 'name' => 'Brian')
assert_equal 'Goodbye Brian', template.render('name' => 'Brian')
assert_equal({'greeting'=>'Goodbye'}, template.assigns)
end
def test_assigns_not_polluted_from_template
template = Template.parse(%|{{ test }}{% assign test = 'bar' %}{{ test }}|)
template.assigns['test'] = 'baz'
assert_equal 'bazbar', template.render
assert_equal 'bazbar', template.render
assert_equal 'foobar', template.render('test' => 'foo')
assert_equal 'bazbar', template.render
end
def test_hash_with_default_proc
template = Template.parse(%|Hello {{ test }}|)
assigns = Hash.new { |h,k| raise "Unknown variable '#{k}'" }
assigns['test'] = 'Tobi'
assert_equal 'Hello Tobi', template.render!(assigns)
assigns.delete('test')
e = assert_raises(RuntimeError) {
template.render!(assigns)
}
assert_equal "Unknown variable 'test'", e.message
end
end