diff --git a/Using-Liquid-without-Rails.textile b/Using-Liquid-without-Rails.textile index 9e3f473..2df620e 100644 --- a/Using-Liquid-without-Rails.textile +++ b/Using-Liquid-without-Rails.textile @@ -12,7 +12,8 @@ end And you have a chunk of text that you want to Liquidize by inserting some details about your products: -
sentence = "I'm running to the store with {{ product.price }} dollars in my pocket to buy a {{ product.name }}."
+sentence = "I'm running to the store with {{ product.price }} dollars in my pocket "
+sentence += "to buy a {{ product.name }}."
And you create a product and parse the sentence:
@@ -21,7 +22,8 @@ puts Liquid::Template.parse(sentence).render('product' => my_purchase)I'm running to the store with Liquid error: undefined method `to_liquid' for # dollars in my pocket to buy a Liquid error: undefined method `to_liquid' for #.
+I'm running to the store with Liquid error: undefined method `to_liquid' for #
to_liquid? Where did that come from? Turns out you need to add a method to your class that returns your instance variables as part of a hash. (Liquid was built to be very paranoid about not letting people access something they're not supposed to, so you need to explicitly let liquid know how to access everything in your object.) So we update the Product class description to include that method: