Create custom tag/filter with parameters

I’m trying to write a custom tag for my Jekyll-based site that receives a bibtex string and replaces/removes some content.

The tag receives a bibtex string like this:

@article{heineman2001component,
title={Component-based software engineering},
author={Heineman, George T and Councill, William T},
journal={Putting the pieces together},
pages={5},
year={2001}
}

and the ruby code is the following:

module Jekyll
  class RenderBibTag < Liquid::Tag
   def initialize(tag_name, input, tokens)
      super
      @input = input
   end

   def render(context)
      output = (@input)#.gsub(/\bjournal\b[\w\s= \{\-\.\,\(\)]+\},/,'')
      return output;
   end
  end
end

Liquid::Template.register_tag('render_bib', Jekyll::RenderBibTag)

Using the tag from the Jekyll template as follows works fine

{%render_bib bibstring %} #bibstring is the string above

When I try to use a Jekyll variable (e.g., page.bibtex which has the bibtex string)

{%render_bib page.bibtex %} 

it does not recognise/pass the string.

Any thoughts?

Your tag doesn’t render properly with variables because, the tag doesn’t detect and evaluate the variable.
You might want to go through the following file to understand how Jekyll’s own include tag handles variables…