Topic: Liquid Markup - Drops?

OK, I've been using Rails for just over a month and have successfully deployed a now-fairly-major site with Rails. Everything's going great, I'm using REST, coding to DRY methods, and life is good.

However, I've been stuck for a few days now.

A little bit of site background: It's an advertising site, and currently webmasters can chose from formats of advert box in terms of layout, with options for styles.

I'm now trying to implement Liquid (http://www.liquidmarkup.org) to allow customisation of boxes down at the HTML level.

My generator looks like this:

  def generate
    settings = Box.find params[:box_id]
    settings.website = Website.find params[:site_id]
    if not settings or not settings.website then
      @output = "<!-- No such adbox. Invalid arguments. -->"
      return
    end
    @adverts = getads(settings, settings.website, request.env['REMOTE_ADDR'], settings.xnum * settings.ynum)
    @tmpl = Skin.find(settings.skin_id).content
    @settings = settings
  end

The view looks like this:
document.write('<!-- ISKsense Renderer --><%= 
Liquid::Template.parse(@tmpl).render('adverts' => @adverts, 'box_settings' => Box.find(params[:box_id]), 'website_settings' => @settings.website)
#@tmpl.inspect.to_s+@adverts.inspect.to_s+@settings.inspect.to_s
-%><!-- ISKsense Renderer END -->')

Now, basically this should work. When the inspect line is uncommented I get all the adverts, settings, everything as expected.

When my markup does a loop it gets the right number of elements and loops- but I can't get any attributes. I can see that {% for advert in adverts %} {{advert}} {% endfor %} gives me the Advert class. But I am unable to access advert.id, advert.text, advert.title...

Liquid did complain about 'Drops', and I sort of worked this out and added lib/skin_drop.rb, which contains:

class SkinDrop < Liquid::Drop
  def before_method
    nil
  end
  def to_liquid
    self
  end
end

And likewise for AdvertDrop

That made the errors go away (undefined to_liquid for #Advert blah) but now leaves me in this current state.

I've been asking in #rubyonrails for nearly 48 hours every 45 minutes and have had no response- anyone on here got any ideas?

Last edited by James Harrison (2007-10-07 18:25:57)

Re: Liquid Markup - Drops?

Bump- does anyone know of any similar tools?