oktapodi
oktapodi

Reputation: 755

Liquid Templates Not Parsing!

Im trying to use Liquid Template Language in my Rails Application, i've watched Ryan Bates' video over at rails cast, i pretty much follow the instructions but it just doesnt seem to work!

When I try something like

@template = Liquid::Template.parse("Hi {{name}}")
@template.render('name' => 'toby')

I get

hi toby

but when i try something like

category = Category.first
@template = Liquid::Template.parse("Hi {{category.name}}")
@template.render('category' => category)

I don't get the desired result, I get only

hi ""

Can someone please help me out with this?

Upvotes: 2

Views: 1228

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176562

When the value is not a hash, you need to tell liquid which methods it can read from the passed object.

This documentation page show you how to instruct ActiveRecord. The quickest way is to use the liquid_methods macro.

Upvotes: 2

Related Questions