Translating a short bit of Ruby code (get next Saturday's date) into Liquid?

26 0 1


I recently found a bit of Ruby which creates a function to output the date of next Saturday (or whatever day you feed it):

require 'date'

def date_of_next()
  date  = Date.parse("Saturday")
  delta = date > ? 0 : 7
  date + delta

As you can see, it's super-compact. Would it be an easy task to translate this into Liquid? (I'd have thought it's possible, seeing as Liquid is apparently based on Ruby - or am I wrong? I'm very new to this!)

Shopify Partner
1807 211 374

This is an accepted solution.

Liquid engine is indeed running on Ruby, but you can't use any Ruby code directly in the Liquid. I would suggest you to move these bits onto a client side and use JavaScript instead of liquid.

Sergiu Svinarciuc | CTO @
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to or our blog