mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07:00
description from Ian Leitch from 9/21/2006
Updated Liquid Drops (markdown)
+5
-5
@@ -1,12 +1,12 @@
|
|||||||
# Liquid Drops
|
# Liquid Drops
|
||||||
|
|
||||||
Drops let you provide the user with custom functionality. They're very much like a standard Ruby class, but have all un-needed and potentialy dangerous methods removed. From the user's perspective a drop acts very much like a Hash, thought methods are accessed with dot-notation aswell as element selection. A drop method cannot be invoked with arguments. Drops are called just-in-time thus allowing you to lazily load objects.
|
Drops let you provide the user with custom functionality. They are very much like a standard Ruby class, but have all unused and potentially dangerous methods removed. From the user's perspective a drop acts very much like a Hash, though methods are accessed with dot-notation as well as element selection. A drop method cannot be invoked with arguments. Drops are called just-in-time, thus allowing you to lazily load objects.
|
||||||
|
|
||||||
## Standard drop methods:
|
## Standard drop methods:
|
||||||
|
|
||||||
before_method(method):
|
before_method(method):
|
||||||
|
|
||||||
Called once for every invokation, even if the destination method doesn't exist. Can be used to provide dynamically named methods.
|
Called once for every invocation, even if the destination method doesn't exist. Can be used to provide dynamically named methods.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -44,15 +44,15 @@ Returns the drop instance.
|
|||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
@product[:name]
|
@product["name"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
@product[:description]
|
@product["description"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def price
|
def price
|
||||||
@product[:price]
|
@product["price"]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user