Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:33:41+00:00 2026-06-07T10:33:41+00:00

I spent today trying to do something simple with Jekyll for http://bitcoin.org/clients.html We have

  • 0

I spent today trying to do something simple with Jekyll for http://bitcoin.org/clients.html

We have a list of Bitcoin software, and every so often that page gets regenerated. It would be good if the order of clients would be randomised for equal exposure.

{% random page.clients %}
{% for client in page.clients %}
  ...

I’m sure it’s simple:

class Random < Liquid::Tag
  def initialize(tag_name, collection_name, tokens)
    @collection_name = collection_name.to_s
    super
  end

  def render(context)
    collection = context[@collection_name]
    collection = collection.sort_by{rand}
    context[@collection_name] = collection
    super
  end
end

Liquid::Template.register_tag('random', Random)

Why doesn’t it work? I see absolutely no change.

I assume I am not assigning to page.clients correctly, because if I try:

context[:foo] = collection

{% random page.clients %}
{% for client in page.clients %}
  ...

Then I get a blank page. But printing @collection_name shows “page.clients”…

Any ideas?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:33:42+00:00Added an answer on June 7, 2026 at 10:33 am
    class Random < Liquid::Tag
      Syntax = /(\w+[.]?\w+)\s+(\w+)/o
    
      def initialize(tag_name, markup, tokens)
        if markup =~ Syntax
          @collection_name = $1
          @randomized_name = $2
        else
          raise SyntaxError.new("Syntax Error in 'random' - Valid syntax: random [source] [var]")
        end
        super
      end
    
      def render(context)
        collection = context[@collection_name]
        collection = collection.sort_by{rand}
        context[@randomized_name] = collection
        return
      end
    end
    
    Liquid::Template.register_tag('random', Random)
    

    And:

          {% random page.clients clients %}
          {% for client in clients %}
             ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent the better part of today trying to figure this out and
Have spent an hour trying to solve this - but to no avail. I'm
I have spent several hours today reading up on doing Custom Routing in ASP.NET
quick question. I am trying to get C++ nailed down, and today I spent
Today I spent a good three hours trying to convert the project MvcContrib.Samples.InputBuilders, included
I've spent a lot of time today trying to figure out how to get
Today I spent about 20 minutes trying to figure out why this worked as
I've spent quite a lot of time today trying various things, but none of
I must be stuck on stoopid today because I spent over an hour trying
I've spent some time today playing with getting the source for python 3.1.1 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.